Skip to content

Commit 16f571b

Browse files
committed
Add tests
1 parent 8cb9ac9 commit 16f571b

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

tests/cases/conformance/types/conditional/conditionalTypes1.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,10 @@ function f21<T extends number | string>(x: T, y: ZeroOf<T>) {
163163
y = x; // Error
164164
}
165165

166+
type T35<T extends { a: string, b: number }> = T[];
167+
type T36<T> = T extends { a: string } ? T extends { b: number } ? T35<T> : never : never;
168+
type T37<T> = T extends { b: number } ? T extends { a: string } ? T35<T> : never : never;
169+
166170
type Extends<T, U> = T extends U ? true : false;
167171
type If<C extends boolean, T, F> = C extends true ? T : F;
168172
type Not<C extends boolean> = If<C, false, true>;
@@ -317,3 +321,14 @@ type NonFooKeys2<T extends object> = Exclude<keyof T, 'foo'>;
317321

318322
type Test1 = NonFooKeys1<{foo: 1, bar: 2, baz: 3}>; // "bar" | "baz"
319323
type Test2 = NonFooKeys2<{foo: 1, bar: 2, baz: 3}>; // "bar" | "baz"
324+
325+
// Repro from #21729
326+
327+
interface Foo2 { foo: string; }
328+
interface Bar2 { bar: string; }
329+
type FooBar = Foo2 | Bar2;
330+
declare interface ExtractFooBar<FB extends FooBar> { }
331+
332+
type Extracted<Struct> = {
333+
[K in keyof Struct]: Struct[K] extends FooBar ? ExtractFooBar<Struct[K]> : Struct[K];
334+
}

0 commit comments

Comments
 (0)