tree-sitter / tree-sitter-typescript

TypeScript grammar for tree-sitter
MIT License
341 stars 104 forks source link

Generate Error #180

Closed jussij closed 2 years ago

jussij commented 2 years ago

I ran a git clone on the typescript and javascript repositories:

git clone https://github.com/tree-sitter/tree-sitter-typescript
git clone https://github.com/tree-sitter/tree-sitter-javascript

The generate on the javascript project works as expected.

However, when I run the generate on the typescript project I get this error:

Unresolved conflict for symbol sequence:

  'await'  expression  •  '<'  …

Possible interpretations:

  1:  'await'  (binary_expression  expression  •  '<'  expression)                (precedence: 'binary_relation', associativity: Left)
  2:  'await'  (call_expression  expression  •  type_arguments  arguments)        (precedence: 'call')
  3:  'await'  (call_expression  expression  •  type_arguments  template_string)  (precedence: 'call')
  4:  (await_expression  'await'  expression)  •  '<'  …                          (precedence: 'unary_void')

Possible resolutions:

  1:  Specify a higher precedence in `call_expression` and `binary_expression` than in the other rules.
  2:  Specify a higher precedence in `await_expression` than in the other rules.
  3:  Add a conflict for these rules: `call_expression`, `await_expression`, `binary_expression`

Any suggestions?

resolritter commented 2 years ago

tree-sitter-javascript is pinned to commit 2c5b138

https://github.com/tree-sitter/tree-sitter-typescript/blob/98ef311701c51f72c83e5285366e00adb7a446c8/package.json#L22

It's possible that, for some reason, your tree-sitter-javascript in node_modules is not matching that commit (I had this problem recently).

Try the following:

cd node_modules 
rm -rf ./tree-sitter-javascript 
git clone https://github.com/tree-sitter/tree-sitter-javascript 
cd tree-sitter-javascript 
git reset --hard 2c5b138
cd ../..
npm run build-typescript
npm run build-tsx
jussij commented 2 years ago

I can confirm running these commands does fix the issue:

git clone https://github.com/tree-sitter/tree-sitter-javascript
cd tree-sitter-javascript
git reset --hard 2c5b138

Thanks :)