You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Spurious "A type predicate's type must be assignable to its parameter's type" #21185
typePredicates<TaggedRecord>={[TinkeyofTaggedRecord]: (variant: TaggedRecord[keyofTaggedRecord])=>variant is TaggedRecord[T]}
Expected behavior:
Should compile, and does in typescript@2.6.2.
Actual behavior:
Fails to compile in typescript@next with
A type predicate's type must be assignable to its parameter's type.
Type 'TaggedRecord[T]' is not assignable to type 'TaggedRecord[keyof TaggedRecord]'.
Caused by #17912. Before that, the assignability was not checked at all; the constraint of both types was incorrectly any. Now, neither type has a constraint, so they are incorrectly not assignable. Turns out our assignability rules for indexed access types are incomplete.
I'll put up a PR after lunch; I need to write some more tests.
Activity
sandersn commentedon Jan 17, 2018
Caused by #17912. Before that, the assignability was not checked at all; the constraint of both types was incorrectly
any. Now, neither type has a constraint, so they are incorrectly not assignable. Turns out our assignability rules for indexed access types are incomplete.I'll put up a PR after lunch; I need to write some more tests.
sandersn commentedon Jan 17, 2018
Fix is up at #21242