Skip to content

tree-sitter-javascript does not parse import-assertions. #239

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
josteink opened this issue Jan 27, 2023 · 1 comment
Closed

tree-sitter-javascript does not parse import-assertions. #239

josteink opened this issue Jan 27, 2023 · 1 comment
Labels

Comments

@josteink
Copy link

The following piece of code is valid but it is parsed incorrectly:

import testData from './testData.json' assert { type: "json" };

Here's a link to the TypeScript Playground showing that the snippet above is valid JavaScript or TypeScript:

https://www.typescriptlang.org/play?#code/JYWwDg9gTgLgBDApgZxgEQIYw3AZlCEOAcgDoB6JVTbUgK2QgDti4NllFY4BvBATzCIAXHABEDZmLgBfANwAoIA

The output of tree-sitter parse is the following:

(program [0, 0] - [1, 0]
  (import_statement [0, 0] - [0, 63]
    (import_clause [0, 7] - [0, 15]
      (identifier [0, 7] - [0, 15]))
    source: (string [0, 21] - [0, 38]
      (string_fragment [0, 22] - [0, 37]))
    (ERROR [0, 39] - [0, 62]
      (identifier [0, 39] - [0, 45])
      (identifier [0, 48] - [0, 52])
      (identifier [0, 55] - [0, 59]))))

Specification for this syntax can be found here: https://nodejs.org/api/esm.html#node-imports

@josteink josteink added the bug label Jan 27, 2023
@mskelton
Copy link
Contributor

#238

@amaanq amaanq closed this as not planned Won't fix, can't repro, duplicate, stale Aug 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants
@josteink @mskelton @amaanq and others