-
-
Notifications
You must be signed in to change notification settings - Fork 539
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
feat(js_parser): better diagnostic for infer type #243 #308
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
366b00a
to
2e1b442
Compare
2e1b442
to
f80b3b8
Compare
f80b3b8
to
318bf44
Compare
!bench_parser |
318bf44
to
018703e
Compare
Parser Benchmark Results
|
018703e
to
fac7d7a
Compare
Parser conformance results onjs/262
jsx/babel
symbols/microsoft
ts/babel
🔥 Regression (2):
ts/microsoft
🎉 Fixed (2):
|
fac7d7a
to
7730d41
Compare
Regressions are expected:
They have the following code which has a invalid
|
nissy-dev
approved these changes
Sep 18, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for making parser behavior stricter!
7730d41
to
931c981
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
A-Changelog
Area: changelog
A-Formatter
Area: formatter
A-Parser
Area: parser
A-Website
Area: website
L-JavaScript
Language: JavaScript and super languages
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.
Summary
The 'infer' keyword can only be utilized within the 'extends' clause of a conditional type. Using it outside of this context will result in an error. Ensure that any type declarations using 'infer' are correctly placed within the conditional type structure to avoid parsing issues.
Added an error message from the typescript for such cases:
'infer' declarations are only permitted in the 'extends' clause of a conditional type.
Took test cases from the ts repo:
https://github.com/microsoft/TypeScript/blob/9cbcf010ce0701a25f01a2a074000db34f80cc17/tests/baselines/reference/inferTypes1.errors.txt#L124
https://github.com/microsoft/TypeScript/blob/9cbcf010ce0701a25f01a2a074000db34f80cc17/tests/baselines/reference/templateLiteralTypes1.errors.txt#L5
Test Plan
cargo test