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 2020-12-03 to 2021-02-16 #632

Merged
merged 2 commits into from Jul 5, 2021

Conversation

alangpierce
Copy link
Owner

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

Changes:
8478027d1a Make sure babel parser throws exactly same recoverable errors when estree plugin is enabled (#12375)
🚫 Only affects error handling.

3bd6a3d781 Make sure estree test should not throw if babel parser does not throw (#12443)
🚫 estree/test code not relevant to Sucrase.

285402d82f Add StaticBlock to Table of Contents in AST spec (#12449)
🚫 Docs only.

2ba9265198 Add missing semicolon in AST spec (#12454)
🚫 Docs only.

b422c7f0ef [babel 8] Disallow sequence expressions in JSX expression containers (#12447)
🚫 Only affects error handling.

e901454096 v7.12.10
🚫 Release only.

a0c1a9a9e4 Disallow non octal decimal escape before use strict (#12366)
🚫 Only affects error handling.

a1acfba387 v7.12.11
🚫 Release only.

0dbc3dd4a0 Add errorRecovery option to type definitions in babel-parser (#12564)
🚫 Type definitions only.

fbef603c43 Report a SyntaxError for } and > in JSX text (#12451)
🚫 Error handling only.

e8b08523f4 docs: add package-specific documentation links (#12531)
🚫 Docs only.

c1473e30b2 [ts]Add optional property to OptionalCallExpression node that has type arguments (#12562)
🚫 AST only.

6c9a481e83 @babel/preset-typescript: fix tsx assigment issue (#12599)
🚫 Bug doesn't appear in Sucrase.

62290aa1ba [babel 8] Don't create TSParenthesizedType nodes by default (#12608)
🚫 AST only.

568679e301 fix: start TypePredicate node after returnToken (#12678)
🚫 AST only.

8fcba6eb55 Raise recoverable error for await expressions in sync functions (#12520)
🚫 Validation only.

fbfd1b2aa6 fix(parser): throw error with wrong typescript 'export declare' (#12684)
🚫 Validation only.

45fdde0ce2 (ts) Throw for abstract methods in a non-abstract class (#12686)
🚫 Validation only.

8cf0a757d5 Recover from "missing semicolon" errors (#12437)
🚫 Validation only.

108564fdad refactor: raise AwaitNotInAsyncContext when an AwaitExpression will be parsed (#12716)
🚫 Validation only.

ecfe20395b spec: disable await binding identifier within static block (#12661)
🚫 Validation only.

20664a430e Permit %%placeholder%% in left-hand-side of a let declaration (#12725)
🚫 Sucrase does not support placeholders.

d291edbdf1 v7.12.13
🚫 Release only.

94ba66c89b fix(ts): allow abstract methods with export default abstract class (#12748)
🚫 Bug fix in validation code.

dd18d87152 v7.12.14
🚫 Release only.

d1cf66e8c1 fix(ts): include leading operator in TSUnionType and TSIntersectionType locations (#12757)
🚫 AST only.

b1921d2d9b v7.12.15
🚫 Release only.

eccbcca948 [TS] Create TSUnionType or TSIntersectionType when typealias has a leading operator (#12758)
🚫 AST only.

bf523da0b0 fix(ts): include asserts in TSTypePredicate location (#12763)
🚫 AST only.

e735266dee Avoid importing .json files (#12759)
🚫 Babel-internal change.

d242ea04c8 babel-parser(ts): Raise recoverable error for abstract interface (#12771)
🚫 Only affects AST and error handling.

f1a327506e ts: Throw recoverable for duplicates access modifier (#12775)
🚫 Validation only.

c07185207c [parser] Fix scope handling of Flow declared functions (#12735)
🚫 Reported bug seems to work fine in Sucrase. The identifier role seems to be missing for flow declare function, but the
impact is unclear, and flow support is lower priority anyway.

dd5c9f958c v7.12.16
🚫 Release only.

c22e72eb24 Raise recoverable error for type members with invalid modifiers (#12785)
🚫 Validation only.

4819ce70e4 refactor: fix typo in error.js (#12808)
🚫 Docs only.

8e9143f06f fix(ts): parse multiline declarations correctly (#12776)
βœ… Ported the change and also added tests and better docs for tsParseDeclaration. This also surfaced other issues with this
code, which I fixed and wrote tests for.

@codecov
Copy link

codecov bot commented Jul 5, 2021

Codecov Report

Merging #632 (a558e84) into main (ac33cea) will increase coverage by 0.28%.
The diff coverage is 82.60%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #632      +/-   ##
==========================================
+ Coverage   82.16%   82.44%   +0.28%     
==========================================
  Files          56       56              
  Lines        5646     5880     +234     
  Branches     1330     1327       -3     
==========================================
+ Hits         4639     4848     +209     
- Misses        724      749      +25     
  Partials      283      283              
Impacted Files Coverage Ξ”
src/parser/plugins/typescript.ts 84.23% <82.60%> (+1.68%) ⬆️
src/util/formatTokens.ts 70.58% <0.00%> (-10.06%) ⬇️
src/parser/util/identifier.ts 90.90% <0.00%> (-4.10%) ⬇️
src/util/shouldElideDefaultExport.ts 77.77% <0.00%> (-3.48%) ⬇️
src/util/getClassInfo.ts 87.85% <0.00%> (-1.85%) ⬇️
src/parser/plugins/jsx/index.ts 91.33% <0.00%> (-1.48%) ⬇️
src/parser/plugins/flow.ts 63.78% <0.00%> (-1.28%) ⬇️
src/identifyShadowedGlobals.ts 87.80% <0.00%> (-1.09%) ⬇️
src/parser/traverser/expression.ts 88.10% <0.00%> (-0.11%) ⬇️
src/Options.ts 100.00% <0.00%> (ΓΈ)
... and 21 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Ξ” = absolute <relative> (impact), ΓΈ = not affected, ? = missing data
Powered by Codecov. Last update ac33cea...a558e84. Read the comment docs.

@github-actions
Copy link

github-actions bot commented Jul 5, 2021

Benchmark results

Before this PR: 293 thousand lines per second
After this PR: 294.5 thousand lines per second

Measured change: 0.51% faster (0.81% slower to 1.75% faster)
Summary: Likely no significant difference

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

Changes:
8478027d1a Make sure babel parser throws exactly same recoverable errors when estree plugin is enabled (#12375)
🚫 Only affects error handling.

3bd6a3d781 Make sure estree test should not throw if babel parser does not throw (#12443)
🚫 estree/test code not relevant to Sucrase.

285402d82f Add StaticBlock to Table of Contents in AST spec (#12449)
🚫 Docs only.

2ba9265198 Add missing semicolon in AST spec (#12454)
🚫 Docs only.

b422c7f0ef [babel 8] Disallow sequence expressions in JSX expression containers (#12447)
🚫 Only affects error handling.

e901454096 v7.12.10
🚫 Release only.

a0c1a9a9e4 Disallow non octal decimal escape before use strict (#12366)
🚫 Only affects error handling.

a1acfba387 v7.12.11
🚫 Release only.

0dbc3dd4a0 Add errorRecovery option to type definitions in babel-parser (#12564)
🚫 Type definitions only.

fbef603c43 Report a SyntaxError for `}` and `>` in JSX text (#12451)
🚫 Error handling only.

e8b08523f4 docs: add package-specific documentation links (#12531)
🚫 Docs only.

c1473e30b2 [ts]Add optional property to OptionalCallExpression node that has type arguments (#12562)
🚫 AST only.

6c9a481e83 @babel/preset-typescript: fix tsx assigment issue (#12599)
🚫 Bug doesn't appear in Sucrase.

62290aa1ba [babel 8] Don't create `TSParenthesizedType` nodes by default (#12608)
🚫 AST only.

568679e301 fix: start TypePredicate node after returnToken (#12678)
🚫 AST only.

8fcba6eb55 Raise recoverable error for await expressions in sync functions (#12520)
🚫 Validation only.

fbfd1b2aa6 fix(parser): throw error with wrong typescript 'export declare' (#12684)
🚫 Validation only.

45fdde0ce2 (ts) Throw for abstract methods in a non-abstract class (#12686)
🚫 Validation only.

8cf0a757d5 Recover from "missing semicolon" errors (#12437)
🚫 Validation only.

108564fdad refactor: raise AwaitNotInAsyncContext when an AwaitExpression will be parsed (#12716)
🚫 Validation only.

ecfe20395b spec: disable await binding identifier within static block (#12661)
🚫 Validation only.

20664a430e Permit %%placeholder%% in left-hand-side of a let declaration (#12725)
🚫 Sucrase does not support placeholders.

d291edbdf1 v7.12.13
🚫 Release only.

94ba66c89b fix(ts): allow abstract methods with `export default abstract class` (#12748)
🚫 Bug fix in validation code.

dd18d87152 v7.12.14
🚫 Release only.

d1cf66e8c1 fix(ts): include leading operator in `TSUnionType` and `TSIntersectionType` locations (#12757)
🚫 AST only.

b1921d2d9b v7.12.15
🚫 Release only.

eccbcca948 [TS] Create `TSUnionType` or `TSIntersectionType` when typealias has a leading operator (#12758)
🚫 AST only.

bf523da0b0 fix(ts): include `asserts` in `TSTypePredicate` location (#12763)
🚫 AST only.

e735266dee Avoid importing `.json` files (#12759)
🚫 Babel-internal change.

d242ea04c8 babel-parser(ts): Raise recoverable error for abstract interface (#12771)
🚫 Only affects AST and error handling.

f1a327506e ts: Throw recoverable for duplicates access modifier (#12775)
🚫 Validation only.

c07185207c [parser] Fix scope handling of Flow declared functions (#12735)
🚫 Reported bug seems to work fine in Sucrase. The identifier role seems to be missing for flow `declare function`, but the impact is unclear, and flow support is lower priority anyway.

dd5c9f958c v7.12.16
🚫 Release only.

c22e72eb24 Raise recoverable error for type members with invalid modifiers (#12785)
🚫 Validation only.

4819ce70e4 refactor: fix typo in error.js (#12808)
🚫 Docs only.

8e9143f06f fix(ts): parse multiline declarations correctly (#12776)
βœ… Ported the change and also added tests and better docs for `tsParseDeclaration`.
@alangpierce alangpierce force-pushed the port-babel-parser-2020-12-03-to-2021-02-16 branch from 198f58d to b31dbd9 Compare July 5, 2021 20:26
@alangpierce alangpierce merged commit fa424bd into main Jul 5, 2021
@alangpierce alangpierce deleted the port-babel-parser-2020-12-03-to-2021-02-16 branch July 5, 2021 21:27
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.

None yet

1 participant