-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
fix(scope-manager): correct analysis of inferred types in conditional types #2537
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
Conversation
Thanks for the PR, @dinofx! typescript-eslint is a 100% community driven project, and we are incredibly grateful that you are contributing to that community. The core maintainers work on this in their personal time, so please understand that it may not be possible for them to review your work immediately. Thanks again! 🙏 Please, if you or your company is finding typescript-eslint valuable, help us sustain the project by sponsoring it transparently on https://opencollective.com/typescript-eslint. As a thank you, your profile/company logo will be added to our main README which receives thousands of unique visitors per day. |
Codecov Report
@@ Coverage Diff @@
## master #2537 +/- ##
=======================================
Coverage 92.82% 92.82%
=======================================
Files 290 290
Lines 9505 9506 +1
Branches 2664 2664
=======================================
+ Hits 8823 8824 +1
Misses 323 323
Partials 359 359
Flags with carried forward coverage won't be shown. Click here to find out more.
|
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.
Fix itself LGTM!
To help prevent regressions, could you please add a new snapshot test into packages/scope-manager/tests/fixtures/type-declaration
Call it something like conditional-nested.ts
The test should be something like:
type Test<T> = T extends Array<infer U>
? U
: T extends Set<infer U>
? U
Then you can cd pacakges/scope-manager && yarn test fixtures -u
to update the snapshot.
What we're looking for here is a snapshot wherein there are two separate U
variables created each with their own reference.
If you're not sure what to look for, just push the snapshot and I will be able to verify it.
Co-authored-by: Brad Zacher <brad.zacher@gmail.com>
Added the new fixture and snapshot |
@bradzacher are any other changes needed? |
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.
LGTM - thanks for doing this!
This fixes #2526
In a conditional type, the inferred types are not in scope in the "if false" type.