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

Properly handle optional arrow params without type annotations #389

Merged
merged 1 commit into from
Jan 3, 2019

Conversation

alangpierce
Copy link
Owner

Fixes #387

I reworked typedParseConditional significantly from the Babel implementation
and didn't realize that I needed to preserve bare ? tokens to denote the
parameter optional. Fortunately, the optional case will always be ?, or ?)
(an initializer isn't allowed when the param is optional), and neither of those
cases is valid as the start of a ternary, so we can distinguish optional param
from ternary with only one token of lookahead.

Fixes #387

I reworked `typedParseConditional` significantly from the Babel implementation
and didn't realize that I needed to preserve bare `?` tokens to denote the
parameter optional. Fortunately, the optional case will always be `?,` or `?)`
(an initializer isn't allowed when the param is optional), and neither of those
cases is valid as the start of a ternary, so we can distinguish optional param
from ternary with only one token of lookahead.
@codecov-io
Copy link

Codecov Report

Merging #389 into master will increase coverage by 0.06%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #389      +/-   ##
==========================================
+ Coverage    79.8%   79.86%   +0.06%     
==========================================
  Files          45       45              
  Lines        4937     5161     +224     
  Branches     1147     1148       +1     
==========================================
+ Hits         3940     4122     +182     
- Misses        699      739      +40     
- Partials      298      300       +2
Impacted Files Coverage Δ
src/parser/plugins/types.ts 95% <100%> (+5%) ⬆️
src/util/formatTokens.ts 70.58% <0%> (-10.06%) ⬇️
src/parser/util/identifier.ts 90.9% <0%> (-4.1%) ⬇️
src/parser/plugins/jsx/index.ts 87.33% <0%> (-1.88%) ⬇️
src/parser/plugins/flow.ts 62.21% <0%> (-1.59%) ⬇️
src/util/getClassInfo.ts 85.12% <0%> (-1.21%) ⬇️
src/identifyShadowedGlobals.ts 87.8% <0%> (-1.09%) ⬇️
src/parser/traverser/statement.ts 80.28% <0%> (-0.77%) ⬇️
src/util/isIdentifier.ts 100% <0%> (ø) ⬆️
src/parser/util/whitespace.ts 100% <0%> (ø) ⬆️
... and 14 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 cd1912c...8359a89. Read the comment docs.

@alangpierce alangpierce merged commit 3356992 into master Jan 3, 2019
@alangpierce alangpierce deleted the handle-bare-optional-arrow-params branch January 3, 2019 06:00
@kiliancs
Copy link

kiliancs commented Jan 3, 2019

That was fast! Thank you!

@alangpierce alangpierce changed the title Properly handle optional arrow params without type parameters Properly handle optional arrow params without type annotations Jan 4, 2019
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.

3 participants