tree-sitter / tree-sitter-typescript

TypeScript grammar for tree-sitter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

missing optional_chain node in call_expression

raczosala opened this issue · comments

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.

my bad you can capture it with ?.