Skip to content

Commit 56710dd

Browse files
committed
Accept new baselines
1 parent 16f571b commit 56710dd

File tree

4 files changed

+550
-366
lines changed

4 files changed

+550
-366
lines changed

tests/baselines/reference/conditionalTypes1.errors.txt

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ tests/cases/conformance/types/conditional/conditionalTypes1.ts(159,5): error TS2
6464
tests/cases/conformance/types/conditional/conditionalTypes1.ts(160,5): error TS2322: Type 'T' is not assignable to type 'ZeroOf<T>'.
6565
Type 'string | number' is not assignable to type 'ZeroOf<T>'.
6666
Type 'string' is not assignable to type 'ZeroOf<T>'.
67-
tests/cases/conformance/types/conditional/conditionalTypes1.ts(250,9): error TS2403: Subsequent variable declarations must have the same type. Variable 'z' must be of type 'T1', but here has type 'Foo<T & U>'.
68-
tests/cases/conformance/types/conditional/conditionalTypes1.ts(275,43): error TS2322: Type 'T95<U>' is not assignable to type 'T94<U>'.
67+
tests/cases/conformance/types/conditional/conditionalTypes1.ts(254,9): error TS2403: Subsequent variable declarations must have the same type. Variable 'z' must be of type 'T1', but here has type 'Foo<T & U>'.
68+
tests/cases/conformance/types/conditional/conditionalTypes1.ts(279,43): error TS2322: Type 'T95<U>' is not assignable to type 'T94<U>'.
6969
Type 'boolean' is not assignable to type 'true'.
7070

7171

@@ -318,6 +318,10 @@ tests/cases/conformance/types/conditional/conditionalTypes1.ts(275,43): error TS
318318
!!! error TS2322: Type 'string' is not assignable to type 'ZeroOf<T>'.
319319
}
320320

321+
type T35<T extends { a: string, b: number }> = T[];
322+
type T36<T> = T extends { a: string } ? T extends { b: number } ? T35<T> : never : never;
323+
type T37<T> = T extends { b: number } ? T extends { a: string } ? T35<T> : never : never;
324+
321325
type Extends<T, U> = T extends U ? true : false;
322326
type If<C extends boolean, T, F> = C extends true ? T : F;
323327
type Not<C extends boolean> = If<C, false, true>;
@@ -477,4 +481,15 @@ tests/cases/conformance/types/conditional/conditionalTypes1.ts(275,43): error TS
477481

478482
type Test1 = NonFooKeys1<{foo: 1, bar: 2, baz: 3}>; // "bar" | "baz"
479483
type Test2 = NonFooKeys2<{foo: 1, bar: 2, baz: 3}>; // "bar" | "baz"
484+
485+
// Repro from #21729
486+
487+
interface Foo2 { foo: string; }
488+
interface Bar2 { bar: string; }
489+
type FooBar = Foo2 | Bar2;
490+
declare interface ExtractFooBar<FB extends FooBar> { }
491+
492+
type Extracted<Struct> = {
493+
[K in keyof Struct]: Struct[K] extends FooBar ? ExtractFooBar<Struct[K]> : Struct[K];
494+
}
480495

tests/baselines/reference/conditionalTypes1.js

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

164+
type T35<T extends { a: string, b: number }> = T[];
165+
type T36<T> = T extends { a: string } ? T extends { b: number } ? T35<T> : never : never;
166+
type T37<T> = T extends { b: number } ? T extends { a: string } ? T35<T> : never : never;
167+
164168
type Extends<T, U> = T extends U ? true : false;
165169
type If<C extends boolean, T, F> = C extends true ? T : F;
166170
type Not<C extends boolean> = If<C, false, true>;
@@ -315,6 +319,17 @@ type NonFooKeys2<T extends object> = Exclude<keyof T, 'foo'>;
315319

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

319334

320335
//// [conditionalTypes1.js]
@@ -517,6 +532,20 @@ declare type ZeroOf<T extends number | string | boolean> = T extends number ? 0
517532
declare function zeroOf<T extends number | string | boolean>(value: T): ZeroOf<T>;
518533
declare function f20<T extends string>(n: number, b: boolean, x: number | boolean, y: T): void;
519534
declare function f21<T extends number | string>(x: T, y: ZeroOf<T>): void;
535+
declare type T35<T extends {
536+
a: string;
537+
b: number;
538+
}> = T[];
539+
declare type T36<T> = T extends {
540+
a: string;
541+
} ? T extends {
542+
b: number;
543+
} ? T35<T> : never : never;
544+
declare type T37<T> = T extends {
545+
b: number;
546+
} ? T extends {
547+
a: string;
548+
} ? T35<T> : never : never;
520549
declare type Extends<T, U> = T extends U ? true : false;
521550
declare type If<C extends boolean, T, F> = C extends true ? T : F;
522551
declare type Not<C extends boolean> = If<C, false, true>;
@@ -624,3 +653,15 @@ declare type Test2 = NonFooKeys2<{
624653
bar: 2;
625654
baz: 3;
626655
}>;
656+
interface Foo2 {
657+
foo: string;
658+
}
659+
interface Bar2 {
660+
bar: string;
661+
}
662+
declare type FooBar = Foo2 | Bar2;
663+
declare interface ExtractFooBar<FB extends FooBar> {
664+
}
665+
declare type Extracted<Struct> = {
666+
[K in keyof Struct]: Struct[K] extends FooBar ? ExtractFooBar<Struct[K]> : Struct[K];
667+
};

0 commit comments

Comments
 (0)