Skip to content
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

bug: incorrect parsing of type definition #295

Open
2 tasks done
jrvidal opened this issue May 7, 2024 · 0 comments
Open
2 tasks done

bug: incorrect parsing of type definition #295

jrvidal opened this issue May 7, 2024 · 0 comments
Labels

Comments

@jrvidal
Copy link

jrvidal commented May 7, 2024

Did you check existing issues?

  • I have read all the tree-sitter docs if it relates to using the parser
  • I have searched the existing issues of tree-sitter-typescript

Tree-Sitter CLI Version, if relevant (output of tree-sitter --version)

7b4275d

Describe the bug

I'm getting highlight errors on some type definitions, and it seems like the cause is here, upstream.

Steps To Reproduce/Bad Parse Tree

type Foo = import('node:fs').ReadStream & {
  bar();
};
(program [0, 0] - [3, 0]
  (type_alias_declaration [0, 0] - [0, 17]
    name: (type_identifier [0, 5] - [0, 8])
    value: (type_identifier [0, 11] - [0, 17]))
  (expression_statement [0, 17] - [2, 2]
    (binary_expression [0, 17] - [2, 1]
      left: (member_expression [0, 17] - [0, 39]
        object: (parenthesized_expression [0, 17] - [0, 28]
          (string [0, 18] - [0, 27]
            (string_fragment [0, 19] - [0, 26])))
        property: (property_identifier [0, 29] - [0, 39]))
      right: (object [0, 42] - [2, 1]
        (ERROR [1, 2] - [1, 8]
          (property_identifier [1, 2] - [1, 5])
          (formal_parameters [1, 5] - [1, 7]))))))
repro.ts	   0.15 ms	   370 bytes/ms	(MISSING ";" [0, 17] - [0, 17])

Expected Behavior/Parse Tree

As far as I can tell this is valid TypeScript (see playground link below), so the parse tree should not contain errors.

Repro

Playground link

@jrvidal jrvidal added the bug label May 7, 2024
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

1 participant