From 975845a68f1dddfa0ebf8e9601667dc7276df81f Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Mon, 10 Dec 2018 13:08:05 -0800 Subject: [PATCH] Add regression test --- .../types/conditional/conditionalTypes2.ts | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/tests/cases/conformance/types/conditional/conditionalTypes2.ts b/tests/cases/conformance/types/conditional/conditionalTypes2.ts index be758945469..4b65b5ddeb2 100644 --- a/tests/cases/conformance/types/conditional/conditionalTypes2.ts +++ b/tests/cases/conformance/types/conditional/conditionalTypes2.ts @@ -147,3 +147,46 @@ type B2 = type C2 = T extends object ? { [Q in keyof T]: C2; } : T; + +// Repro from #28654 + +type MaybeTrue = true extends T["b"] ? "yes" : "no"; + +type T0 = MaybeTrue<{ b: never }> // "no" +type T1 = MaybeTrue<{ b: false }>; // "no" +type T2 = MaybeTrue<{ b: true }>; // "yes" +type T3 = MaybeTrue<{ b: boolean }>; // "yes" + +// Repro from #28824 + +type Union = 'a' | 'b'; +type Product = { f1: A, f2: B}; +type ProductUnion = Product<'a', 0> | Product<'b', 1>; + +// {a: "b"; b: "a"} +type UnionComplement = { + [K in Union]: Exclude +}; +type UCA = UnionComplement['a']; +type UCB = UnionComplement['b']; + +// {a: "a"; b: "b"} +type UnionComplementComplement = { + [K in Union]: Exclude> +}; +type UCCA = UnionComplementComplement['a']; +type UCCB = UnionComplementComplement['b']; + +// {a: Product<'b', 1>; b: Product<'a', 0>} +type ProductComplement = { + [K in Union]: Exclude +}; +type PCA = ProductComplement['a']; +type PCB = ProductComplement['b']; + +// {a: Product<'a', 0>; b: Product<'b', 1>} +type ProductComplementComplement = { + [K in Union]: Exclude> +}; +type PCCA = ProductComplementComplement['a']; +type PCCB = ProductComplementComplement['b'];