Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Port babel-parser changes from 2023-03-20 to 2023-06-15
Instructions: https://github.com/alangpierce/sucrase/wiki/Porting-changes-from-Babel's-parser 032203ea18 chore: Update TS 5.0.2 (#15502) 🚫 Babel-internal change. 656403b49f refactor: introduce `lookaheadInLineCharCode` (#15510) 🚫 I considered porting this refactor for `await using`, but decided against it. 202e4fa60b v7.21.4 🚫 Release only. 35c09db4f3 perf: Improve the code quality of `@babe/parser` for ts (#15540) 🚫 Code changes are minor and generally don't affect Sucrase. bc7f795024 fix: Remove `mixins` and `implements` for `DeclareInterface` and `InterfaceDeclaration` (#15539) 🚫 AST-only. 0a1cfc0ed6 Babel 8 misc changes (#15068) 🚫 Comment-only change not affecting Sucrase. 86df74531d v7.21.5 🚫 Release only. 29426297d6 Remove `using await` restriction in explicitResourceManagement (#15602) 🚫 Only affects error handling, not relevant to Sucrase. 8fd99c8f48 v7.21.8 🚫 Release only. 2b70257372 chore: Enable rule `no-import-type-side-effects` (#15627) 🚫 Babel-internal change. c5f68eb62e rescan gt token at the end of type args parsing (#15631) ✅ Added test and implemented fix similarly. Fixes #797. 0ad567f913 v7.21.9 🚫 Release only. 920b78c0c2 Enable regexp unicode sets parsing by default (#15638) 🚫 Doesn't affect Sucrase. 56a6c85aca Parse `await using` declarations (#15520) ✅ Implemented using a simpler backtracking method for now. 4b5ebdc9b3 Add support for the updated import attributes proposal (#15536) ✅ Implemented with a small tweak to Sucrase implementation. 7e5e7bf2f8 Unify parsing of import/export modifiers (type/typeof/module) (#15630) 🚫 Skipped for now, since it's prep work for later import syntax changes and I want to wait for that to settle a little more. 560b8ac523 [ts] Support `import ... =` and `export =` in scripts (#15497) 🚫 Sucrase already supported this behavior. 389ecb08ed v7.22.0 🚫 Release only. 325fe683d8 v7.22.3 🚫 Release only. 35116224d2 Mark `assert` attributes with `extra.deprecatedAssertSyntax` (#15667) 🚫 AST only. eb4aa876b2 v7.22.4 🚫 Release only. ecc819bf75 [babel 8] Require Node.js `^16.20.0 || ^18.16.0 || >=20.0.0` (#15585) 🚫 Babel-internal change. 72006cb657 Use Prettier v3.0.0-alpha.12 (#15617) 🚫 Babel-internal change. 08564ea230 v7.22.5 🚫 Release only. be8fccd6f3 chore: Run `readmes.js` in CI (#15690) 🚫 Babel-internal change. 980b63c829 Use more optional chaining (#15703) 🚫 Babel-internal.
- Loading branch information
1 parent
7284b37
commit b509898
Showing
11 changed files
with
257 additions
and
52 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 was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import {ContextualKeyword} from "../parser/tokenizer/keywords"; | ||
import {TokenType as tt} from "../parser/tokenizer/types"; | ||
import type TokenProcessor from "../TokenProcessor"; | ||
|
||
/** | ||
* Starting at a potential `with` or (legacy) `assert` token, remove the import | ||
* attributes if they exist. | ||
*/ | ||
export function removeMaybeImportAttributes(tokens: TokenProcessor): void { | ||
if ( | ||
tokens.matches2(tt._with, tt.braceL) || | ||
(tokens.matches2(tt.name, tt.braceL) && tokens.matchesContextual(ContextualKeyword._assert)) | ||
) { | ||
// assert | ||
tokens.removeToken(); | ||
// { | ||
tokens.removeToken(); | ||
tokens.removeBalancedCode(); | ||
// } | ||
tokens.removeToken(); | ||
} | ||
} |
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
Oops, something went wrong.