Skip to content

Retain substitution types through instantiation if possible#30059

Merged
weswigham merged 1 commit into
microsoft:masterfrom
weswigham:retain-substitutions
Feb 26, 2019
Merged

Retain substitution types through instantiation if possible#30059
weswigham merged 1 commit into
microsoft:masterfrom
weswigham:retain-substitutions

Conversation

@weswigham
Copy link
Copy Markdown
Member

Fixes #29677

The alias lacked the correct constraint because the constraint was implied by the substitution type, which disappeared when the type alias was instantiated with the outer type parameters. The correct behavior is to retain substitution types through instantiation if their type variable is still a type variable upon instantiation.

This required correctly handling substitution types on the target side in inference (other tests needed the change to continue to work as expected), naturally, since, eg, an Extract<K, string>'s true branch is now going to look like a substitution of K instead of K directly.

Copy link
Copy Markdown
Member

@sandersn sandersn left a comment

Choose a reason for hiding this comment

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

Code looks good and the justification sounds theoretically good. Since I'm the middle of the current ember break from variance testing on conditional types, though, I can't help be surprised that nothing breaks. This PR would be a good candidate for the "bot, test DT on this" feature once you get it working.

@microsoft microsoft deleted a comment from typescript-bot Feb 23, 2019
@microsoft microsoft deleted a comment from typescript-bot Feb 23, 2019
@microsoft microsoft deleted a comment from typescript-bot Feb 23, 2019
@microsoft microsoft deleted a comment from typescript-bot Feb 23, 2019
@microsoft microsoft deleted a comment from typescript-bot Feb 23, 2019
@microsoft microsoft deleted a comment from typescript-bot Feb 23, 2019
@weswigham
Copy link
Copy Markdown
Member Author

@typescript-bot test this & @typescript-bot run dt

@typescript-bot
Copy link
Copy Markdown
Collaborator

typescript-bot commented Feb 23, 2019

Heya @weswigham, I've started to run the extended test suite on this PR at 4fc9428. You can monitor the build here. It should now contribute to this PR's status checks.

@typescript-bot
Copy link
Copy Markdown
Collaborator

typescript-bot commented Feb 23, 2019

Heya @weswigham, I've started to run the Definitely Typed test suite on this PR at 4fc9428. You can monitor the build here. It should now contribute to this PR's status checks.

@weswigham
Copy link
Copy Markdown
Member Author

weswigham commented Feb 23, 2019

@RyanCavanaugh the bot has learned how to run DT tests on PRs. It takes like an hour and a half; use it sparingly~ (Also is DT is dirty, as it is today, I think you'll need to comb through the log to see what's a new failure by hand, though maybe @sandersn knows more)

@weswigham
Copy link
Copy Markdown
Member Author

DT looks good~

@weswigham weswigham merged commit c506148 into microsoft:master Feb 26, 2019
@weswigham weswigham deleted the retain-substitutions branch February 26, 2019 01:10
@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.

3 participants