tree-sitter / tree-sitter-typescript

TypeScript grammar for tree-sitter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add support for `satisfies`

mjambon opened this issue · comments

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

const a = 42 satisfies number;

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

https://www.typescriptlang.org/play?ts=4.9.5#code/MYewdgzgLgBAhjAvDALAJhhOUCWEBmOAphDGAK4C2ARkQE4DcAUEA

The output of tree-sitter parse is the following:

 tree-sitter-prod parse <(echo 'const a = 42 satisfies number;')
(program [0, 0] - [1, 0]
  (lexical_declaration [0, 0] - [0, 30]
    (variable_declarator [0, 6] - [0, 29]
      name: (identifier [0, 6] - [0, 7])
      (ERROR [0, 10] - [0, 22]
        (number [0, 10] - [0, 12])
        (identifier [0, 13] - [0, 22]))
      value: (identifier [0, 23] - [0, 29]))))
/dev/fd/63	0 ms	(ERROR [0, 10] - [0, 22])

Documentation: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-9.html#the-satisfies-operator

Originally reported here: semgrep/semgrep#7197

Hya, I'm looking to build a linter for TS in Haskell.
For this, I'll need to use haskell-tree-sitter which depends on this lib.
Is there any chance of getting support for the satisfies operator anytime soon?

If not, some pointers on how to add it would be useful. I might try and add support for it myself, Thanks!

Looks like this was fixed in #228