Skip to content

Force inner indexed access simplification during inference, if possible#28420

Merged
weswigham merged 3 commits intomicrosoft:masterfrom
weswigham:react-inference-improvement
Nov 12, 2018
Merged

Force inner indexed access simplification during inference, if possible#28420
weswigham merged 3 commits intomicrosoft:masterfrom
weswigham:react-inference-improvement

Conversation

@weswigham
Copy link
Copy Markdown
Member

Fixes #28394

This is effectively an extension of #27953 - getSimplifiedType refrains from simplifying indexed accesses whose index is still generic, as it might later be instantiated and require outer distribution; however since we're in the middle of inference, we're just interested in breaking down our types as far as they'll go to find matching patterns; we're not concerned with the target side's ability to be further instantiated, since we're just looking for one of our goal type variables.

@weswigham weswigham added this to the TypeScript 3.2 milestone Nov 9, 2018
Comment thread tests/baselines/reference/tsxReactPropsInferenceSuceedsOnIntersections.js Outdated
Comment thread src/compiler/checker.ts Outdated
Comment thread src/compiler/checker.ts

function distributeIndexOverObjectType(objectType: Type, indexType: Type) {
// (T | U)[K] -> T[K] | U[K]
if (objectType.flags & TypeFlags.Union) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're a bad person for not testing this branch.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excuse me, I'm just reusing an operation already in use elsehwere ☑️

@weswigham weswigham merged commit 13234b6 into microsoft:master Nov 12, 2018
@weswigham weswigham deleted the react-inference-improvement branch November 12, 2018 22:39
@microsoft microsoft locked as resolved and limited conversation to collaborators Oct 21, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants