You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I import only types from .astro files to the .stories.ts, it outputs an error and doesn't start.
Unexpected token (1:23)
Stack trace:
at pp$4.raise (node_modules/acorn/dist/acorn.mjs:3640:13)
at pp$9.expect (node_modules/acorn/dist/acorn.mjs:760:26)
at pp$8.parseImport (node_modules/acorn/dist/acorn.mjs:1845:28)
at pp$8.parseTopLevel (node_modules/acorn/dist/acorn.mjs:823:21)
at Function.parse (node_modules/acorn/dist/acorn.mjs:645:35)
error: script "astrobook" exited with code 1
The text was updated successfully, but these errors were encountered:
The problem is the acorn parser used during the consumption of story files.
It is only equipped to handle jsx. So an explicit type import or type syntax will cause a syntax error.
* Parses the content of the given file and returns all its exports
*/
exportfunctiongetExports(code: string): string[]{
// Parse the code into an AST
constparser=Parser.extend(jsx())
constast=parser.parse(code,{
sourceType: 'module',
ecmaVersion: 'latest',
allowImportExportEverywhere: true,
})
The only way to fix this is to transpile typescript first before consuming it or use a different parser.
As a quick fix you could avoid using that syntax and configure your project with: tsconfig.json
When I import only types from
.astro
files to the.stories.ts
, it outputs an error and doesn't start.The text was updated successfully, but these errors were encountered: