-
Notifications
You must be signed in to change notification settings - Fork 645
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Summary: Fixes the parsing of multiple TypeScript as expressions in a row. Previously `x as any as number` was parsed as `x as (any as number)`, instead of `(x as any) as number`. This was because we customized the precedence calculation for `as` in the function getPrecedenceExcept, but this custom precedence was not saved in the stack. Later when we had an as expression in the stack, we were not getting the right precedence level for it when doing `getPrecedence(stack.back().opKind)`. Fix this by checking for `identifier` specially and converting the `as` identifier to a new token kind, `as_operator`, before pushing onto the stack. This can be extended to implement `satisfies` as well. Reviewed By: tmikov Differential Revision: D49700751 fbshipit-source-id: 68d4fd7552cb90c3196d546c53989a5f29ba7add
- Loading branch information
1 parent
66d3f87
commit 07604e3
Showing
6 changed files
with
72 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters