From 16f571b026b829266a90789be46e136dd0b013b8 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Mon, 19 Mar 2018 16:29:00 -0700 Subject: [PATCH] Add tests --- .../types/conditional/conditionalTypes1.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/cases/conformance/types/conditional/conditionalTypes1.ts b/tests/cases/conformance/types/conditional/conditionalTypes1.ts index 3ef044625eb..f21bfaadf82 100644 --- a/tests/cases/conformance/types/conditional/conditionalTypes1.ts +++ b/tests/cases/conformance/types/conditional/conditionalTypes1.ts @@ -163,6 +163,10 @@ function f21(x: T, y: ZeroOf) { y = x; // Error } +type T35 = T[]; +type T36 = T extends { a: string } ? T extends { b: number } ? T35 : never : never; +type T37 = T extends { b: number } ? T extends { a: string } ? T35 : never : never; + type Extends = T extends U ? true : false; type If = C extends true ? T : F; type Not = If; @@ -317,3 +321,14 @@ type NonFooKeys2 = Exclude; type Test1 = NonFooKeys1<{foo: 1, bar: 2, baz: 3}>; // "bar" | "baz" type Test2 = NonFooKeys2<{foo: 1, bar: 2, baz: 3}>; // "bar" | "baz" + +// Repro from #21729 + +interface Foo2 { foo: string; } +interface Bar2 { bar: string; } +type FooBar = Foo2 | Bar2; +declare interface ExtractFooBar { } + +type Extracted = { + [K in keyof Struct]: Struct[K] extends FooBar ? ExtractFooBar : Struct[K]; +}