Closed bpstrngr closed 1 year ago
I parse the same code, but it didnt throw an error. this is my case
export default abstract class FunctionBase extends NodeBase {
declare async: boolean;
}
acorn.Parser.extend(tsPlugin({
jsx: {
allowNamespaces: true
}
})).parse(input, {
sourceType: 'module',
ecmaVersion: 'latest',
locations: true
})
okay interesting, i looked around, i'm using one additional plugin, https://github.com/xtuc/acorn-import-attributes, and taking that out fixes this. It actually has a newer version than the one i'm using (an upgrade to import attributes instead of import assertions), besides an open issue regarding an export declaration, so i'll take a test with it. really hope it won't interfere cuz these compositions of overriding get nasty to track for me.
well, the mentioned plugin's new version causes other interferences when turned on... extending acorn with it before acorn-typescript causes .d.ts files to fail ("SyntaxError: Missing initializer in const declaration: export const VERSION;"), while after it's line break between regular importnamedspecifiers that become "unexpected token".
Since now thinking about it it's not that surprising that importassertions interfere with typescript, i suppose either some typescript-ready variant of acorn-import-attributes, or some detection of its presence here would be required...
I think i could drop support for import-assertions in typescript though for now anyway..
All right, maybe we can support import-assertions in acorn-typescript
in the future
I think this issue could be a feature request
support in version acorn-typescript@1.4.6
While parsing Rollup's src/ast/nodes/shared/FunctionBase.ts:
acorn expects a semicolon after the "abstract" keyword.