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
typeWhat<Kextendsstring>={x: {y: 0,z: 1}}extends{x: {[PinK]: 0}} ? true : false;// What<K> is eagerly simplified to false before instantiation of KtypeHuh=What<"y">// expected: true, actual: false.
Expected behavior: What<"y"> should evaluate to true, since { x: { y: 0, z: 1 } } extends { x: { y: 0 } }
Actual behavior: What<"y"> evaluates to false; in face the definition of What<K> gets reduced to just false before K is ever instantiated (at least according to quickinfo)
Related Issues: #39364 and #30152 both seem to be in the general category of "over-eager reduction of generic conditional type" but the particulars might not be the same
TypeScript Version: 4.0.5 and 4.2.0-dev.20201120
Search Terms: conditional, generic, eager/premature/incorrect, reduction/resolution/collapse/simplification
Code
Expected behavior:
What<"y">
should evaluate totrue
, since{ x: { y: 0, z: 1 } }
extends{ x: { y: 0 } }
Actual behavior:
What<"y">
evaluates tofalse
; in face the definition ofWhat<K>
gets reduced to justfalse
beforeK
is ever instantiated (at least according to quickinfo)Playground Link: Provided
Related Issues:
#39364 and #30152 both seem to be in the general category of "over-eager reduction of generic conditional type" but the particulars might not be the same
From this SO question. @ahejlsberg said this issue is not the same as #39364 so I should open a new issue.
A possible wrinkle: this problem does not seem to exist if we "unwrap" the outer object type:
The text was updated successfully, but these errors were encountered: