tree-sitter / tree-sitter-typescript

TypeScript grammar for tree-sitter
MIT License
332 stars 103 forks source link

missing optional_chain node in call_expression #258

Closed raczosala closed 11 months ago

raczosala commented 11 months ago

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

bar?.();

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

https://www.typescriptlang.org/play?#code/EYQwTg-AdAFAlAbiA

The output of tree-sitter parse is the following:

(program [0, 0] - [1, 0]
  (expression_statement [0, 0] - [0, 8]
    (call_expression [0, 0] - [0, 7]
      function: (identifier [0, 0] - [0, 3])
      arguments: (arguments [0, 5] - [0, 7]))))

The optional_chain node should be part into the AST, or, at the very least, it should be identifiable through unnamed nodes.

raczosala commented 11 months ago

my bad you can capture it with ?.