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

Fix parsing of methods and fields named "declare" #575

Merged
merged 1 commit into from
Dec 30, 2020

Conversation

alangpierce
Copy link
Owner

Fixes #545

When originally porting babel/babel#11146, there was a
mistake where we were using eatContextual when actually it was important to
use tsParseModifier, since tsParseModifier won't eat a name token if the
following token indicates that it must be the name of a method or field. This PR
fixes that by switching to tsParseModifier as Babel does.

It might be good to later refactor/simplify tsParseModifier if the keyword
specificity is just for error handling (and to maybe avoid the
snapshot/restore), but that can be a follow-up.

Fixes #545

When originally porting babel/babel#11146, there was a
mistake where we were using `eatContextual` when actually it was important to
use `tsParseModifier`, since `tsParseModifier` won't eat a name token if the
following token indicates that it must be the name of a method or field. This PR
fixes that by switching to `tsParseModifier` as Babel does.

It might be good to later refactor/simplify `tsParseModifier` if the keyword
specificity is just for error handling (and to maybe avoid the
snapshot/restore), but that can be a follow-up.
@codecov-io
Copy link

Codecov Report

Merging #575 (b56e364) into master (18709a7) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #575   +/-   ##
=======================================
  Coverage   81.94%   81.94%           
=======================================
  Files          55       55           
  Lines        5806     5806           
  Branches     1313     1313           
=======================================
  Hits         4758     4758           
  Misses        764      764           
  Partials      284      284           
Impacted Files Coverage Δ
src/parser/traverser/statement.ts 82.61% <100.00%> (ø)

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 18709a7...b56e364. Read the comment docs.

@alangpierce alangpierce merged commit b3190e2 into master Dec 30, 2020
@alangpierce alangpierce deleted the fix-method-named-declare branch December 30, 2020 05:57
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.

breaking change from 3.13 to 3.15
2 participants