Skip to content

Add inference priority for mapped type keys#22246

Merged
weswigham merged 4 commits into
masterfrom
multiple-inferences-then-choose-them-all
Mar 5, 2018
Merged

Add inference priority for mapped type keys#22246
weswigham merged 4 commits into
masterfrom
multiple-inferences-then-choose-them-all

Conversation

@weswigham
Copy link
Copy Markdown
Member

The new priority causes union inference, similar to the return type inference priority.

Fixes #22242

@weswigham weswigham force-pushed the multiple-inferences-then-choose-them-all branch from 381012e to f48dfb0 Compare February 28, 2018 23:56
Copy link
Copy Markdown
Member

@DanielRosenwasser DanielRosenwasser left a comment

Choose a reason for hiding this comment

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

Apart from my spelling nit, this looks good. Just tackle this.

Comment thread src/compiler/types.ts Outdated
AlwaysStrict = 1 << 4, // Always use strict rules for contravariant inferences
NakedTypeVariable = 1 << 0, // Naked type variable in union or intersection type
HomomorphicMappedType = 1 << 1, // Reverse inference for hoimomorphic mapped type
MappedType = 1 << 2, // Reverse inference for mapped type
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.

MappedTypeConstraint

@weswigham
Copy link
Copy Markdown
Member Author

@DanielRosenwasser done. Build break is fixed by #22247

The new priority causes union inference, similarly to return type
@weswigham weswigham force-pushed the multiple-inferences-then-choose-them-all branch from 8046705 to 9e12919 Compare March 1, 2018 01:56
Comment thread src/compiler/types.ts Outdated
NoConstraints = 1 << 3, // Don't infer from constraints of instantiable types
AlwaysStrict = 1 << 4, // Always use strict rules for contravariant inferences
NakedTypeVariable = 1 << 0, // Naked type variable in union or intersection type
HomomorphicMappedType = 1 << 1, // Reverse inference for hoimomorphic mapped type
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.

typo: homomorphic.
Also I think it would be more accurate to say "inference made to a reverse" instead of "reverse inference for" on this line and the next.

@weswigham weswigham merged commit 53ae507 into master Mar 5, 2018
@weswigham weswigham deleted the multiple-inferences-then-choose-them-all branch March 5, 2018 21:19
@microsoft microsoft locked and limited conversation to collaborators Jul 25, 2018
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.

4 participants