tree-sitter / tree-sitter-javascript

Javascript grammar for tree-sitter
MIT License
314 stars 108 forks source link

class A{;} #286

Closed vird closed 3 months ago

vird commented 3 months ago

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

class A{;}

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

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

The output of tree-sitter parse is the following:

> tree-sitter-javascript@0.20.1 parse
> tree-sitter parse "1.js"

(program [0, 0] - [1, 0]
  (class_declaration [0, 0] - [0, 10]
    name: (identifier [0, 6] - [0, 7])
    body: (class_body [0, 7] - [0, 10]
      (ERROR [0, 8] - [0, 9]))))
1.js    0 ms    (ERROR [0, 8] - [0, 9])