TypeScript Version: next (3.4.0-dev.20190330), latest (3.4.1)
Search Terms:
- tuple conditional type
- tuple compare
- tuple comparison
Code
type Not<T extends boolean> = [T] extends [true] ? false : true;
type NoOp<T extends boolean> = Not<Not<T>>; // always expands true (see intellisense)
type t0 = Not<Not<false>>; // false
type t1 = NoOp<false>; // true (but should be false)
Expected behavior:
Type t1 must be false and NoOp must be of the nested conditional type that depends on T, but not of simple true unit type.
Actual behavior:
As you see, something is broken when you use generic argument for tuple comparison in conditional type, because when you expand your types manually (t0 is an expanded representation of t1) it works as expected.
Playground Link:
Klick me
Related Issues:
This bug report originated from my stackoverflow question.
Additional credits to @dragomirtitian and @fictitious for helping and localizing the bug to a minimal representation.
TypeScript Version: next (
3.4.0-dev.20190330), latest (3.4.1)Search Terms:
Code
Expected behavior:
Type
t1must befalseandNoOpmust be of the nested conditional type that depends onT, but not of simpletrueunit type.Actual behavior:
As you see, something is broken when you use generic argument for tuple comparison in conditional type, because when you expand your types manually (
t0is an expanded representation oft1) it works as expected.Playground Link:
Klick me
Related Issues:
This bug report originated from my stackoverflow question.
Additional credits to @dragomirtitian and @fictitious for helping and localizing the bug to a minimal representation.