Skip to content

Check type guard constraint conformance#17314

Merged
sandersn merged 2 commits into
microsoft:masterfrom
gcnew:checkTypeGuardConstraintConformance
Jul 20, 2017
Merged

Check type guard constraint conformance#17314
sandersn merged 2 commits into
microsoft:masterfrom
gcnew:checkTypeGuardConstraintConformance

Conversation

@gcnew
Copy link
Copy Markdown
Contributor

@gcnew gcnew commented Jul 20, 2017

Fixes #17297

type Keys = 'a'|'b'|'c'
type KeySet<T extends Keys> = { [k in T]: true }

// now an error: Type 'T | "d"' does not satisfy the constraint 'Keys'
declare function hasKey<T extends Keys>(x: KeySet<T>): x is KeySet<T|'d'>;

@RyanCavanaugh
Copy link
Copy Markdown
Member

Restarted Travis due to lint problems

@sandersn sandersn merged commit 759ee28 into microsoft:master Jul 20, 2017
@sandersn
Copy link
Copy Markdown
Member

Thanks @gcnew! Nice find on the bug too.

@microsoft microsoft locked and limited conversation to collaborators Jun 14, 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