Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement optional chaining deletion (#492)
Progress toward #461 Tech plan: https://github.com/alangpierce/sucrase/wiki/Sucrase-Optional-Chaining-and-Nullish-Coalescing-Technical-Plan This ended up being a relatively small tweak to the optional chaining implementation: * There's a new helper that wraps the optionalChain helper, and I needed to add a way for helpers to depend on each other. * In most cases, we condition on the delete and non-delete cases based on whether there's a delete token just before the start of the optional chain. * To determine whether a subscript is the last of its chain (and therefore needs a delete operation), we can walk the tokens forward tracking depth until we get to either another subscript or the end of the chain. This means there was no need for any changes to the parser. Since it only walks between two adjacent subscripts, it takes linear extra time unless there's nesting, and only ever does the more expensive operation when processing an optional delete.
- Loading branch information
1 parent
b475b8c
commit 8b7a4f7
Showing
5 changed files
with
130 additions
and
13 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