WIP: update for latest tree-sitter-javascript #84
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We're running into errors when using the latest javascript grammar which includes changes to support optional chaining (
?.tree-sitter/tree-sitter-javascript#137).part 1 (done)
Some of the errors were the same as described and fixed by @maxbrunsfeld for javascript and were due to rules being copied from javascript rather than automatically inherited. The first two commits (b4b4e19 and 60a517f) apply the same fixes as were applied on the javascript grammar. They allow
new A.B()to be parsed correctly. These changes also add support for?.incall_expressionsince it was not automatically inherited from javascript.part 2 (done)
Several tests specific to typescript still fail. The first one I'm looking at is "type assertions". The expression<A>b.cis parsed incorrectly as(<A>b).cand I haven't figured out how to fix it. My understanding is that_expressionhas the lowest precedence (0) and thetype_assertionrule is essentially seq(type_arguments, _expression) and has with a higher precedence than all of_expression, while the precedence onmember_expression(b.c) has no impact here due to being a choice within_expression. I tried declaring_expressionas inline, hoping it might do something but then the generator takes several minutes to terminate (and reports a conflict). There are a few more things I want to try but let me know if you have ideas.I solved this eventually by changing the precedence of
type_assertionfrom the highest to the same as_expression(zero). I can't tell why its precedence used to be high. It looks reasonable to me now and the "Type assertions" test passes. This is commit b4b4e19.part 3 (done)
Function calls with type arguments(returns wrong tree)We were failing to parse
new A<B>(). Fixed by moving the dynamic precedence annotation innew_expression.part 4 (in progress)
The 'less than' operatori.e. parsinga < b.c;(takes the wrong path, returns ERROR node)