-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Use tuple context based on apparent type of the contextual type uninstantiated by return mapper #62174
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?
Conversation
…tantiated by return mapper
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 fixes a recent inference regression related to tuple typing by improving contextual typing for array literals when return type mapping is involved. The change ensures that array literals receive proper tuple context even when the contextual type is instantiated by a return mapper.
Key changes:
- Introduces a new
SkipReturnMapper
context flag to control when return mapper instantiation is applied - Modifies array literal checking to consider tuple context from both the standard contextual type and the contextual type without return mapper instantiation
- Adds comprehensive test cases demonstrating the fix for both built-in and custom Promise implementations
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
src/compiler/types.ts |
Adds new SkipReturnMapper context flag enum value |
src/compiler/checker.ts |
Implements the fix by modifying contextual type resolution and array literal checking logic |
tests/cases/compiler/returnTypeContextualTupleTyping1.ts |
Adds regression test cases for the tuple typing fix |
tests/baselines/reference/returnTypeContextualTupleTyping1.types |
Expected type output baseline for the new test |
tests/baselines/reference/returnTypeContextualTupleTyping1.symbols |
Expected symbol output baseline for the new test |
tests/baselines/reference/inferFromGenericFunctionReturnTypes3.types |
Updated baseline showing improved tuple inference behavior |
Comments suppressed due to low confidence (2)
@typescript-bot test it |
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 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 Something interesting changed - please have a look. Details
|
repro for the above break: TS playground, EDIT:// and its smaller version: TS playground |
This comment was marked as spam.
This comment was marked as spam.
I think the above cast in the repro case should just be allowed. I opened a new issue about this: #62177 |
🤖 AI Assistant: Task completed: PR #62174: Use tuple context based on apparent type of the contextual type uninstantiated by return ... |
fixes #62071
it's a somewhat cheap shot at this recent inference regression