-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Don't defer index types for non-generic substitution types #61999
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
base: main
Are you sure you want to change the base?
Don't defer index types for non-generic substitution types #61999
Conversation
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.
Pull Request Overview
This PR ensures that index types on non-generic substitution types are resolved immediately (instead of deferred), addressing #61728.
- Added two new compiler tests to verify index lookups on non-generic substitution types.
- Modified
getIndexTypeinchecker.tsto bypass deferral when bothbaseTypeandconstraintare non-generic.
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| tests/cases/compiler/substitutionTypeNonGenericIndexType1.ts | Adds a test for boolean conditional index resolution on non-generic substitution types. |
| tests/cases/compiler/substitutionTypeNonGenericIndexType2.ts | Adds a test for infer-based index resolution on non-generic substitution types. |
| src/compiler/checker.ts | Updates getIndexType to immediately compute index types for non-generic substitutions. |
Comments suppressed due to low confidence (3)
tests/cases/compiler/substitutionTypeNonGenericIndexType2.ts:1
- [nitpick] Consider adding a reference to GitHub issue #61728 at the top of this test for consistency with related test files.
// @strict: true
tests/cases/compiler/substitutionTypeNonGenericIndexType2.ts:14
- [nitpick] Consider adding additional test cases where either the
baseTypeor theconstraintis generic to ensure this new index type logic covers mixed generic scenarios.
const test: Test["rejectClose"] = "rejectClose";
|
@typescript-bot test it |
|
Hey @jakebailey, I've packed this into an installable tgz. You can install it for testing by referencing it in your and then running There is also a playground for this build and an npm module you can use via |
|
Hey @jakebailey, the results of running the DT tests are ready. Everything looks the same! |
|
@jakebailey Here are the results of running the user tests with tsc comparing There were infrastructure failures potentially unrelated to your change:
Otherwise... Everything looks good! |
|
@jakebailey Here they are:
tscComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
Developer Information: |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@jakebailey Here are the results of running the top 400 repos with tsc comparing Everything looks good! |
fixes #61728