-
Notifications
You must be signed in to change notification settings - Fork 143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Port babel-parser changes from 2019-12-22 to 2020-04-12 #523
Merged
Conversation
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
a18166d2a refactor: remove inClassProperty parser state (#10906) 🚫 Already removed from parser state. 197a8da04 Remove unused parser methods (#10942) 🚫 Already removed. 86245a83a TSTypeCastExpression should not be inside call parameters (#10939) 🚫 Validation only. 30449fe05 Refactor parseSubscript (#10937) 🚫 Skipped the refactor since Sucrase's subscriptStartIndex seems to work nicer when the cases are handled independently. 2f3f77926 refactor: remove unused invalidTemplateEscapePosition tokenizer state (#10935) 🚫 Already removed. 023824426 refactor: remove unecessary checkYieldAwaitInDefaultParams (#10936) 🚫 Already removed. 26eb89187 fix: Class Field Initializer should not allow await expression as immediate child (#10946) 🚫 Scope code not relevant for Sucrase. 6ee8c97e6 Fix: TopLevelAwait should respect await identifiers defined in… (#10947) 🚫 Validation code not relevant to Sucrase. 467667af8 When reading a new string, U+2028/2029 should correctly set th… (#10944) 🚫 Line information not maintained by Sucrase parser. a28353703 fix: check await when parsing AsyncArrowBindingIdentifier (#10953) 🚫 Validation only. 455d782ef test: add invalid-lone-import test (#10950) 🚫 Test only. 8fd532db3 LiteralPropertyName should allow BigIntLiteral (#10955) ✅ Didn't fail tests, but I added the check and a test. 771c730fd [parser] Disallow duplicate and undeclared private names (#10456) 🚫 All related scopes and validation, neither of which we handle. 5b907e9bb [parser] enable dynamic import by default (#10843) 🚫 Already enabled by default in Sucrase. c3388ea42 Enable nullish coalescing by default in @babel/parser (#10819) 🚫 Already enabled by default in Sucrase. 5f807ae45 Enable optional chaining by default in @babel/parser (#10817) 🚫 Already enabled by default in Sucrase. e8dac621d chore: specify package type (#10849) 🚫 Might be good to do for Sucrase, but outside the scope of this change. 81c5f1f22 Disallow private name in object elements and TS type elements (#10980) 🚫 Validation only. 2486615a7 v7.8.0 🚫 Release only. 8fce431d8 Revert "chore: specify package type (#10849)" (#11003) 🚫 Nothing to revert. a7620bd26 v7.8.3 🚫 Release only. 9df70b450 Duplicate `__proto__` key should be allowed in object patterns (#10987) 🚫 Validation only. a1063d258 fix: triple __proto__ in object patterns should be allowed (#11009) 🚫 Validation only. 6648d62f4 chore: use @babel/eslint-config-internal (#11026) 🚫 Lint only. 45301c530 Update coalesce precedence (#11017) ✅ Switched precedence and made sure tests still pass. It's unclear what test could confirm this in terms of Sucrase behavior. 34a965328 add AST for the module attribute proposal (#11015) 🚫 Docs only. 341964bd4 fix: properly parse member expression after property initializ… (#11031) 🚫 Code was no longer in Sucrase. facfd4d8a Enable `no-process-exit` ESLint rule (#11025) 🚫 Lint only. 9bc04baeb fix(babel-parser): avoid state.clone() to clone the whole token store (#11029) 🚫 I already implemented a very similar optimization in a different way. 43b23e086 refactor: simplify toAssignable routine (#11032) 🚫 Sucrase already removed toAssignable. 5c2e6bc07 v7.8.4 🚫 Release only. 11d9826e7 Fix Async Generic After Await Parsing Error (#11092) 🚫 Code change not relevant for Sucrase. 0b3dea8f5 Turn on no-fallthrough rule (#11093) 🚫 Lint only. 8ab27c8ff Wrap type-only class fields in flow comments (#11096) 🚫 Internal-only change. 38529699d Refactor await/yield production parameter tracking (#10956) 🚫 Seems to be only related to scopes and validation. 223cee724 Parse declare modifier around accessibility modifiers (#11146) 🚫 Issue still tracked as #486 afb0f489d Enable more eslint recommended rules (#11168) 🚫 Lint only 750d3dde3 v7.8.6 🚫 Release only 2603c2e22 fix(babel-parser): chain off optionally chained keys named cla… (#11198) 🚫 Seems to be working in Sucrase, and changed code doesn't exist anymore. 21c914187 Refactor: add parser message template (#11192) 🚫 Validation-related change. I might eventually want something like this in Sucrase, but for now, Sucrase isn't focused on error messages. 595f65f33 v7.8.7 🚫 Release only. e297e406c refactor: remove redundant contextDescription empty check (#11219) 🚫 Validation only. 2057d2b15 fix: non-directive "use strict" should not enable parsing in strict mode (#11188) 🚫 Sucrase always parses in strict mode. c831a2450 v7.8.8 🚫 Release only. 84a9ea455 Allow await when it is not in AsyncArrowHead (#11148) 🚫 Validation only. 4a4845585 feat: align ID_Start/ID_Continue regex to Unicode 13.0.0 (#11246) 🚫 We don't validate unicode in identifiers. 20d9a1018 Add estree parsing support for `export * as A` (#11254) 🚫 estree not supported. 740260b23 Add `import type` and `export type` support to TypeScript (#11171) ✅ Ported both changes, though looks like export type doesn't end up working with the transform right now. 2bce1e5e2 Parse BigInts by default (#11117) 🚫 Already parsed by default. 4f394e30d Add support for flow's SymbolTypeAnnotation (#11077) 🚫 We don't parse flow built-in types like babel does. 5c1a8210d Implement support for `declare` on class fields with Flow (#11178) 🚫 Will be done along with #486. 3ce7c2e39 Added support for record and tuple syntax. (#10865) 🚫 I won't support this syntax for now since it's experimental. 841f4428e Rephrase parser error message (#11208) 🚫 Validation only. e39b50803 Add @babel/helper-validator-identifier (#11289) 🚫 I'll keep the identifier checking code inline for now. 8d5e422be v7.9.0 🚫 Release only. 7ca814489 fix: parse value imports named type as values (#11296) 🚫 Seems to work fine in Sucrase. 2399e0df2 v7.9.2 🚫 Release only. 0e5c1da65 fix: async arrow functions should not be allowed after binary… (#11284) 🚫 Validation only. 1ae85560a v7.9.3 🚫 Release only. dc7c5640e Compact parser fixture loc info (#11322) 🚫 Test data change only. 4e6c9c52e fix: token after strict mode block is evaluated in strict mode (#11186) 🚫 Sucrase always uses strict mode. d3cf5fb5f v7.9.4 🚫 Release only. 8b976b067 fix: do not push new token context when function is following dot/questionDot (#11388) 🚫 Sucrase doesn't use token contexts.
Codecov Report
@@ Coverage Diff @@
## master #523 +/- ##
==========================================
+ Coverage 81.42% 81.50% +0.08%
==========================================
Files 55 55
Lines 5706 5710 +4
Branches 1285 1287 +2
==========================================
+ Hits 4646 4654 +8
+ Misses 769 766 -3
+ Partials 291 290 -1
Continue to review full report at Codecov.
|
alangpierce
added a commit
that referenced
this pull request
May 11, 2020
Fixes #520 The PR #523 already added parsing support for type-only import and export syntax, and there was already support for removing `import type` from Flow, so the only new logic was to fully support `export type`. The implementation here is a little ugly; Flow's version sets the tokens as type tokens, whereas the TS version sets the types as regular tokens and removes them at transform type. This seems to be necessary to follow the behavior that `export type` statements do not result in the imported value being elided. Ideally, Sucrase would support the `importsNotUsedAsValues` TS preference in some way, but for now, it keeps the old behavior of eliding type-only imports. The setting `importsNotUsedAsValues=error` should make the distinction irrelevant anyway, so it seems low priority to support.
alangpierce
added a commit
that referenced
this pull request
May 11, 2020
Fixes #520 The PR #523 already added parsing support for type-only import and export syntax, and there was already support for removing `import type` from Flow, so the only new logic was to fully support `export type`. The implementation here is a little ugly; Flow's version sets the tokens as type tokens, whereas the TS version sets the types as regular tokens and removes them at transform type. This seems to be necessary to follow the behavior that `export type` statements do not result in the imported value being elided. Ideally, Sucrase would support the `importsNotUsedAsValues` TS preference in some way, but for now, it keeps the old behavior of eliding type-only imports. The setting `importsNotUsedAsValues=error` should make the distinction irrelevant anyway, so it seems low priority to support.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
a18166d2a refactor: remove inClassProperty parser state (#10906)
🚫 Already removed from parser state.
197a8da04 Remove unused parser methods (#10942)
🚫 Already removed.
86245a83a TSTypeCastExpression should not be inside call parameters (#10939)
🚫 Validation only.
30449fe05 Refactor parseSubscript (#10937)
🚫 Skipped the refactor since Sucrase's subscriptStartIndex seems to work nicer
when the cases are handled independently.
2f3f77926 refactor: remove unused invalidTemplateEscapePosition tokenizer state (#10935)
🚫 Already removed.
023824426 refactor: remove unecessary checkYieldAwaitInDefaultParams (#10936)
🚫 Already removed.
26eb89187 fix: Class Field Initializer should not allow await expression as immediate child (#10946)
🚫 Scope code not relevant for Sucrase.
6ee8c97e6 Fix: TopLevelAwait should respect await identifiers defined in… (#10947)
🚫 Validation code not relevant to Sucrase.
467667af8 When reading a new string, U+2028/2029 should correctly set th… (#10944)
🚫 Line information not maintained by Sucrase parser.
a28353703 fix: check await when parsing AsyncArrowBindingIdentifier (#10953)
🚫 Validation only.
455d782ef test: add invalid-lone-import test (#10950)
🚫 Test only.
8fd532db3 LiteralPropertyName should allow BigIntLiteral (#10955)
✅ Didn't fail tests, but I added the check and a test.
771c730fd [parser] Disallow duplicate and undeclared private names (#10456)
🚫 All related scopes and validation, neither of which we handle.
5b907e9bb [parser] enable dynamic import by default (#10843)
🚫 Already enabled by default in Sucrase.
c3388ea42 Enable nullish coalescing by default in @babel/parser (#10819)
🚫 Already enabled by default in Sucrase.
5f807ae45 Enable optional chaining by default in @babel/parser (#10817)
🚫 Already enabled by default in Sucrase.
e8dac621d chore: specify package type (#10849)
🚫 Might be good to do for Sucrase, but outside the scope of this change.
81c5f1f22 Disallow private name in object elements and TS type elements (#10980)
🚫 Validation only.
2486615a7 v7.8.0
🚫 Release only.
8fce431d8 Revert "chore: specify package type (#10849)" (#11003)
🚫 Nothing to revert.
a7620bd26 v7.8.3
🚫 Release only.
9df70b450 Duplicate
__proto__
key should be allowed in object patterns (#10987)🚫 Validation only.
a1063d258 fix: triple proto in object patterns should be allowed (#11009)
🚫 Validation only.
6648d62f4 chore: use @babel/eslint-config-internal (#11026)
🚫 Lint only.
45301c530 Update coalesce precedence (#11017)
✅ Switched precedence and made sure tests still pass. It's unclear what test
could confirm this in terms of Sucrase behavior.
34a965328 add AST for the module attribute proposal (#11015)
🚫 Docs only.
341964bd4 fix: properly parse member expression after property initializ… (#11031)
🚫 Code was no longer in Sucrase.
facfd4d8a Enable
no-process-exit
ESLint rule (#11025)🚫 Lint only.
9bc04baeb fix(babel-parser): avoid state.clone() to clone the whole token store (#11029)
🚫 I already implemented a very similar optimization in a different way.
43b23e086 refactor: simplify toAssignable routine (#11032)
🚫 Sucrase already removed toAssignable.
5c2e6bc07 v7.8.4
🚫 Release only.
11d9826e7 Fix Async Generic After Await Parsing Error (#11092)
🚫 Code change not relevant for Sucrase.
0b3dea8f5 Turn on no-fallthrough rule (#11093)
🚫 Lint only.
8ab27c8ff Wrap type-only class fields in flow comments (#11096)
🚫 Internal-only change.
38529699d Refactor await/yield production parameter tracking (#10956)
🚫 Seems to be only related to scopes and validation.
223cee724 Parse declare modifier around accessibility modifiers (#11146)
🚫 Issue still tracked as #486
afb0f489d Enable more eslint recommended rules (#11168)
🚫 Lint only
750d3dde3 v7.8.6
🚫 Release only
2603c2e22 fix(babel-parser): chain off optionally chained keys named cla… (#11198)
🚫 Seems to be working in Sucrase, and changed code doesn't exist anymore.
21c914187 Refactor: add parser message template (#11192)
🚫 Validation-related change. I might eventually want something like this in
Sucrase, but for now, Sucrase isn't focused on error messages.
595f65f33 v7.8.7
🚫 Release only.
e297e406c refactor: remove redundant contextDescription empty check (#11219)
🚫 Validation only.
2057d2b15 fix: non-directive "use strict" should not enable parsing in strict mode (#11188)
🚫 Sucrase always parses in strict mode.
c831a2450 v7.8.8
🚫 Release only.
84a9ea455 Allow await when it is not in AsyncArrowHead (#11148)
🚫 Validation only.
4a4845585 feat: align ID_Start/ID_Continue regex to Unicode 13.0.0 (#11246)
🚫 We don't validate unicode in identifiers.
20d9a1018 Add estree parsing support for
export * as A
(#11254)🚫 estree not supported.
740260b23 Add
import type
andexport type
support to TypeScript (#11171)✅ Ported both changes, though looks like export type doesn't end up working
with the transform right now.
2bce1e5e2 Parse BigInts by default (#11117)
🚫 Already parsed by default.
4f394e30d Add support for flow's SymbolTypeAnnotation (#11077)
🚫 We don't parse flow built-in types like babel does.
5c1a8210d Implement support for
declare
on class fields with Flow (#11178)🚫 Will be done along with #486.
3ce7c2e39 Added support for record and tuple syntax. (#10865)
🚫 I won't support this syntax for now since it's experimental.
841f4428e Rephrase parser error message (#11208)
🚫 Validation only.
e39b50803 Add @babel/helper-validator-identifier (#11289)
🚫 I'll keep the identifier checking code inline for now.
8d5e422be v7.9.0
🚫 Release only.
7ca814489 fix: parse value imports named type as values (#11296)
🚫 Seems to work fine in Sucrase.
2399e0df2 v7.9.2
🚫 Release only.
0e5c1da65 fix: async arrow functions should not be allowed after binary… (#11284)
🚫 Validation only.
1ae85560a v7.9.3
🚫 Release only.
dc7c5640e Compact parser fixture loc info (#11322)
🚫 Test data change only.
4e6c9c52e fix: token after strict mode block is evaluated in strict mode (#11186)
🚫 Sucrase always uses strict mode.
d3cf5fb5f v7.9.4
🚫 Release only.
8b976b067 fix: do not push new token context when function is following dot/questionDot (#11388)
🚫 Sucrase doesn't use token contexts.