Skip to content
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 2022-05-01 to 2022-06-27 #719

Merged
merged 2 commits into from
Jul 13, 2022

Conversation

alangpierce
Copy link
Owner

Instructions: https://github.com/alangpierce/sucrase/wiki/Porting-changes-from-Babel's-parser

0e6900d771 Fix parsing ts type casts and nested patterns in destructuring (#14500)
🚫 It looks like this only affects AST transformation and error handling, so not relevant for Sucrase.

e29e915d2e fix: allow liberal named type-as imports (#14522)
βœ… Sucrase already had looser checking and is not affected, but I added a test anyway.

47a3240c39 v7.17.12
🚫 Release only.

9156230e68 Fix parsing of < after object literals with the jsx plugin (#14557)
🚫 Sucrase isn't affected by this issue, seems to be a bug in Babel implementation details that were removed for Sucrase.

d6ff91940f [ts] Add support for instantiation expressions (#14457)
βœ… Implemented by adding back the startsExpr flag on tokens and filling it in based on Babel's definitions. Used updated logic from 2ca44e4951 below. Also implemented typeof and new cases similarly to Babel.

59d24a45d9 [ts 4.7] Support extends constraints for infer (#14476)
βœ… Implemented using logic similar to Babel and TS. Sadly, this requires adding a new state field, which slows down all snapshot/restore and adds some extra work to all type parsing.

6415f091ff [ts 4.7] Support optional variance annotations (#14359)
βœ… Implemented more directly without using the modifiers system, which didn't seem necessary here.

2d5f5ad7fd v7.18.0
🚫 Release only.

f8cf03c067 Fix typo in moduleAttributesVerionPluginOption (#14584)
🚫 Typo not in Sucrase.

4d4db2a95b v7.18.3
🚫 Relase only.

8967ccbdd8 fix: loc.index of some nodes is wrongly enumerable. (#14595)
🚫 AST only.

e8c4b78330 [ts] FIx parsing of nested extends type in arrow type (#14604)
βœ… Set inDisallowConditionalTypesContext for that code path and added test.

64b30c673e Update failing Babel 8 parser fixture (#14615)
🚫 Babel internal change.

5419d84da4 v7.18.4
🚫 Release only.

52cdab724d [babel 8] Recover from error when parsing <T>() => {}</T> (#14616)
🚫 Appears to only affect error handling.

dd75b027e4 feat: Automatically generate test results that do not exist (#14592)
🚫 Babel internal change.

3b206e11a7 Enable test variance-annotations-with-jsx with babel8 (#14626)
🚫 Babel internal change.

352d4d2246 v7.18.5
🚫 Release only.

f8785e973b Rename Babel parser decorator tests (#14665)
🚫 Babel internal change.

2ca44e4951 [ts] Allow ...<...> followed by newline or binary operator (#14636)
βœ… Implemented with same logic as Babel.

f0ec180eb7 Enforce _foo.default || _foo to import lib files in tests (#14673)
🚫 Babel internal change.

4c3365f6bd Enforce setting type in package.json (#14675)
🚫 Babel internal change.

e8dce41083 JSON modules should be imported with default (#14668)
🚫 Only affects validation, so not relevant for Sucrase.

e4e700ebe5 [ts] Disallow property access after instantiation expression (#14650)
🚫 Only affects validation, so not relevant for Sucrase.

7c91b80f31 v7.18.6
🚫 Release only.

Instructions: https://github.com/alangpierce/sucrase/wiki/Porting-changes-from-Babel's-parser

0e6900d771 Fix parsing ts type casts and nested patterns in destructuring (#14500)
🚫 It looks like this only affects AST transformation and error handling, so not relevant for Sucrase.

e29e915d2e fix: allow liberal named type-as imports (#14522)
βœ… Sucrase already had looser checking and is not affected, but I added a test anyway.

47a3240c39 v7.17.12
🚫 Release only.

9156230e68 Fix parsing of `<` after object literals with the `jsx` plugin (#14557)
🚫 Sucrase isn't affected by this issue, seems to be a bug in Babel implementation details that were removed for Sucrase.

d6ff91940f [ts] Add support for instantiation expressions (#14457)
βœ… Implemented by adding back the startsExpr flag on tokens and filling it in based on Babel's definitions. Used updated logic from 2ca44e4951 below. Also implemented typeof and new cases similarly to Babel.

59d24a45d9 [ts 4.7] Support `extends` constraints for `infer` (#14476)
βœ… Implemented using logic similar to Babel and TS. Sadly, this requires adding a new state field, which slows down all snapshot/restore and adds some extra work to all type parsing.

6415f091ff [ts 4.7] Support optional variance annotations (#14359)
βœ… Implemented more directly without using the modifiers system, which didn't seem necessary here.

2d5f5ad7fd v7.18.0
🚫 Release only.

f8cf03c067 Fix typo in moduleAttributesVerionPluginOption (#14584)
🚫 Typo not in Sucrase.

4d4db2a95b v7.18.3
🚫 Relase only.

8967ccbdd8 fix: `loc.index` of some nodes is wrongly enumerable. (#14595)
🚫 AST only.

e8c4b78330 [ts] FIx parsing of nested `extends` type in arrow type (#14604)
βœ… Set inDisallowConditionalTypesContext for that code path and added test.

64b30c673e Update failing Babel 8 parser fixture (#14615)
🚫 Babel internal change.

5419d84da4 v7.18.4
🚫 Release only.

52cdab724d [babel 8] Recover from error when parsing `<T>() => {}</T>` (#14616)
🚫 Appears to only affect error handling.

dd75b027e4 feat: Automatically generate test results that do not exist (#14592)
🚫 Babel internal change.

3b206e11a7 Enable test `variance-annotations-with-jsx` with babel8 (#14626)
🚫 Babel internal change.

352d4d2246 v7.18.5
🚫 Release only.

f8785e973b Rename Babel parser decorator tests (#14665)
🚫 Babel internal change.

2ca44e4951 [ts] Allow `...<...>` followed by newline or binary operator (#14636)
βœ… Implemented with same logic as Babel.

f0ec180eb7 Enforce `_foo.default || _foo` to import lib files in tests (#14673)
🚫 Babel internal change.

4c3365f6bd Enforce setting `type` in `package.json` (#14675)
🚫 Babel internal change.

e8dce41083 JSON modules should be imported with default (#14668)
🚫 Only affects validation, so not relevant for Sucrase.

e4e700ebe5 [ts] Disallow property access after instantiation expression (#14650)
🚫 Only affects validation, so not relevant for Sucrase.

7c91b80f31 v7.18.6
🚫 Release only.
@codecov
Copy link

codecov bot commented Jul 12, 2022

Codecov Report

Merging #719 (10d9db0) into main (173e4fe) will increase coverage by 0.16%.
The diff coverage is 98.61%.

@@            Coverage Diff             @@
##             main     #719      +/-   ##
==========================================
+ Coverage   86.86%   87.03%   +0.16%     
==========================================
  Files          54       54              
  Lines        5665     5700      +35     
  Branches     1333     1341       +8     
==========================================
+ Hits         4921     4961      +40     
+ Misses        472      470       -2     
+ Partials      272      269       -3     
Impacted Files Coverage Ξ”
src/parser/tokenizer/readWordTree.ts 100.00% <ΓΈ> (ΓΈ)
src/transformers/JSXTransformer.ts 97.16% <96.15%> (+0.63%) ⬆️
src/parser/plugins/jsx/xhtml.ts 100.00% <100.00%> (ΓΈ)
src/parser/plugins/typescript.ts 87.23% <100.00%> (+0.83%) ⬆️
src/parser/tokenizer/index.ts 86.05% <100.00%> (+0.09%) ⬆️
src/parser/tokenizer/keywords.ts 100.00% <100.00%> (ΓΈ)
src/parser/tokenizer/state.ts 100.00% <100.00%> (ΓΈ)
src/parser/traverser/expression.ts 88.41% <100.00%> (-0.03%) ⬇️

πŸ“£ Codecov can now indicate which changes are the most critical in Pull Requests. Learn more

@github-actions
Copy link

github-actions bot commented Jul 12, 2022

Benchmark results

Before this PR: 319.1 thousand lines per second
After this PR: 315 thousand lines per second

Measured change: 1.29% slower (1.91% slower to 0.79% faster)
Summary: Likely no significant difference

@alangpierce alangpierce merged commit d85cdda into main Jul 13, 2022
@alangpierce alangpierce deleted the port-babel-parser-2022-05-01-to-2022-06-27 branch July 13, 2022 06:27
1Lighty pushed a commit to Astra-mod/sucrase that referenced this pull request Aug 14, 2022
)

Instructions: https://github.com/alangpierce/sucrase/wiki/Porting-changes-from-Babel's-parser

0e6900d771 Fix parsing ts type casts and nested patterns in destructuring (#14500)
🚫 It looks like this only affects AST transformation and error handling, so not relevant for Sucrase.

e29e915d2e fix: allow liberal named type-as imports (#14522)
βœ… Sucrase already had looser checking and is not affected, but I added a test anyway.

47a3240c39 v7.17.12
🚫 Release only.

9156230e68 Fix parsing of `<` after object literals with the `jsx` plugin (#14557)
🚫 Sucrase isn't affected by this issue, seems to be a bug in Babel implementation details that were removed for Sucrase.

d6ff91940f [ts] Add support for instantiation expressions (#14457)
βœ… Implemented by adding back the startsExpr flag on tokens and filling it in based on Babel's definitions. Used updated logic from 2ca44e4951 below. Also implemented typeof and new cases similarly to Babel.

59d24a45d9 [ts 4.7] Support `extends` constraints for `infer` (#14476)
βœ… Implemented using logic similar to Babel and TS. Sadly, this requires adding a new state field, which slows down all snapshot/restore and adds some extra work to all type parsing.

6415f091ff [ts 4.7] Support optional variance annotations (#14359)
βœ… Implemented more directly without using the modifiers system, which didn't seem necessary here.

2d5f5ad7fd v7.18.0
🚫 Release only.

f8cf03c067 Fix typo in moduleAttributesVerionPluginOption (#14584)
🚫 Typo not in Sucrase.

4d4db2a95b v7.18.3
🚫 Relase only.

8967ccbdd8 fix: `loc.index` of some nodes is wrongly enumerable. (#14595)
🚫 AST only.

e8c4b78330 [ts] FIx parsing of nested `extends` type in arrow type (#14604)
βœ… Set inDisallowConditionalTypesContext for that code path and added test.

64b30c673e Update failing Babel 8 parser fixture (#14615)
🚫 Babel internal change.

5419d84da4 v7.18.4
🚫 Release only.

52cdab724d [babel 8] Recover from error when parsing `<T>() => {}</T>` (#14616)
🚫 Appears to only affect error handling.

dd75b027e4 feat: Automatically generate test results that do not exist (#14592)
🚫 Babel internal change.

3b206e11a7 Enable test `variance-annotations-with-jsx` with babel8 (#14626)
🚫 Babel internal change.

352d4d2246 v7.18.5
🚫 Release only.

f8785e973b Rename Babel parser decorator tests (#14665)
🚫 Babel internal change.

2ca44e4951 [ts] Allow `...<...>` followed by newline or binary operator (#14636)
βœ… Implemented with same logic as Babel.

f0ec180eb7 Enforce `_foo.default || _foo` to import lib files in tests (#14673)
🚫 Babel internal change.

4c3365f6bd Enforce setting `type` in `package.json` (#14675)
🚫 Babel internal change.

e8dce41083 JSON modules should be imported with default (#14668)
🚫 Only affects validation, so not relevant for Sucrase.

e4e700ebe5 [ts] Disallow property access after instantiation expression (#14650)
🚫 Only affects validation, so not relevant for Sucrase.

7c91b80f31 v7.18.6
🚫 Release only.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant