Skip to content

Commit 33c7e7f

Browse files
committed
Accept new baselines
1 parent 71fe8e8 commit 33c7e7f

9 files changed

+229
-105
lines changed

tests/baselines/reference/api/tsserverlibrary.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2390,8 +2390,8 @@ declare namespace ts {
23902390
root: ConditionalRoot;
23912391
checkType: Type;
23922392
extendsType: Type;
2393-
trueType: Type;
2394-
falseType: Type;
2393+
resolvedTrueType: Type;
2394+
resolvedFalseType: Type;
23952395
}
23962396
interface SubstitutionType extends InstantiableType {
23972397
typeVariable: TypeVariable;

tests/baselines/reference/api/typescript.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2390,8 +2390,8 @@ declare namespace ts {
23902390
root: ConditionalRoot;
23912391
checkType: Type;
23922392
extendsType: Type;
2393-
trueType: Type;
2394-
falseType: Type;
2393+
resolvedTrueType: Type;
2394+
resolvedFalseType: Type;
23952395
}
23962396
interface SubstitutionType extends InstantiableType {
23972397
typeVariable: TypeVariable;

tests/baselines/reference/circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.errors.txt

Lines changed: 44 additions & 32 deletions
Large diffs are not rendered by default.

tests/baselines/reference/conditionalTypes1.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,7 @@ declare type T82 = Eq2<false, true>;
645645
declare type T83 = Eq2<false, false>;
646646
declare type Foo<T> = T extends string ? boolean : number;
647647
declare type Bar<T> = T extends string ? boolean : number;
648-
declare const convert: <U>(value: Foo<U>) => Foo<U>;
648+
declare const convert: <U>(value: Foo<U>) => Bar<U>;
649649
declare type Baz<T> = Foo<T>;
650650
declare const convert2: <T>(value: Foo<T>) => Foo<T>;
651651
declare function f31<T>(): void;

tests/baselines/reference/conditionalTypes1.types

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -779,8 +779,8 @@ type Bar<T> = T extends string ? boolean : number;
779779
>Bar : Bar<T>
780780

781781
const convert = <U>(value: Foo<U>): Bar<U> => value;
782-
>convert : <U>(value: Foo<U>) => Foo<U>
783-
><U>(value: Foo<U>): Bar<U> => value : <U>(value: Foo<U>) => Foo<U>
782+
>convert : <U>(value: Foo<U>) => Bar<U>
783+
><U>(value: Foo<U>): Bar<U> => value : <U>(value: Foo<U>) => Bar<U>
784784
>value : Foo<U>
785785
>value : Foo<U>
786786

@@ -832,7 +832,7 @@ function f33<T, U>() {
832832
>T1 : Foo<T & U>
833833

834834
type T2 = Bar<T & U>;
835-
>T2 : Foo<T & U>
835+
>T2 : Bar<T & U>
836836

837837
var z: T1;
838838
>z : Foo<T & U>
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
tests/cases/compiler/conditionalTypesSimplifyWhenTrivial.ts(27,14): error TS2322: Type 'Pick<Params, ExcludeWithDefault<keyof Params, never, never>>' is not assignable to type 'Params'.
2+
'Pick<Params, ExcludeWithDefault<keyof Params, never, never>>' is assignable to the constraint of type 'Params', but 'Params' could be instantiated with a different subtype of constraint '{}'.
3+
tests/cases/compiler/conditionalTypesSimplifyWhenTrivial.ts(31,5): error TS2322: Type 'T' is not assignable to type 'ExcludeWithDefault<T, never, never>'.
4+
tests/cases/compiler/conditionalTypesSimplifyWhenTrivial.ts(36,14): error TS2322: Type 'Pick<Params, ExtractWithDefault<keyof Params, keyof Params, never>>' is not assignable to type 'Params'.
5+
'Pick<Params, ExtractWithDefault<keyof Params, keyof Params, never>>' is assignable to the constraint of type 'Params', but 'Params' could be instantiated with a different subtype of constraint '{}'.
6+
tests/cases/compiler/conditionalTypesSimplifyWhenTrivial.ts(40,5): error TS2322: Type 'T' is not assignable to type 'ExtractWithDefault<T, T, never>'.
7+
tests/cases/compiler/conditionalTypesSimplifyWhenTrivial.ts(47,14): error TS2322: Type 'Pick<Params, TemplatedConditional<keyof Params, never, never, keyof Params>>' is not assignable to type 'Params'.
8+
'Pick<Params, TemplatedConditional<keyof Params, never, never, keyof Params>>' is assignable to the constraint of type 'Params', but 'Params' could be instantiated with a different subtype of constraint '{}'.
9+
tests/cases/compiler/conditionalTypesSimplifyWhenTrivial.ts(51,5): error TS2322: Type 'T' is not assignable to type 'TemplatedConditional<T, never, never, T>'.
10+
tests/cases/compiler/conditionalTypesSimplifyWhenTrivial.ts(56,14): error TS2322: Type 'Pick<Params, TemplatedConditional<keyof Params, keyof Params, keyof Params, never>>' is not assignable to type 'Params'.
11+
'Pick<Params, TemplatedConditional<keyof Params, keyof Params, keyof Params, never>>' is assignable to the constraint of type 'Params', but 'Params' could be instantiated with a different subtype of constraint '{}'.
12+
tests/cases/compiler/conditionalTypesSimplifyWhenTrivial.ts(60,5): error TS2322: Type 'T' is not assignable to type 'TemplatedConditional<T, T, T, never>'.
13+
14+
15+
==== tests/cases/compiler/conditionalTypesSimplifyWhenTrivial.ts (8 errors) ====
16+
const fn1 = <Params>(
17+
params: Pick<Params, Exclude<keyof Params, never>>,
18+
): Params => params;
19+
20+
function fn2<T>(x: Exclude<T, never>) {
21+
var y: T = x;
22+
x = y;
23+
}
24+
25+
const fn3 = <Params>(
26+
params: Pick<Params, Extract<keyof Params, keyof Params>>,
27+
): Params => params;
28+
29+
function fn4<T>(x: Extract<T, T>) {
30+
var y: T = x;
31+
x = y;
32+
}
33+
34+
declare var x: Extract<number | string, any>; // Should be `numebr | string` and not `any`
35+
36+
type ExtractWithDefault<T, U, D = never> = T extends U ? T : D;
37+
38+
type ExcludeWithDefault<T, U, D = never> = T extends U ? D : T;
39+
40+
const fn5 = <Params>(
41+
params: Pick<Params, ExcludeWithDefault<keyof Params, never>>,
42+
): Params => params;
43+
~~~~~~
44+
!!! error TS2322: Type 'Pick<Params, ExcludeWithDefault<keyof Params, never, never>>' is not assignable to type 'Params'.
45+
!!! error TS2322: 'Pick<Params, ExcludeWithDefault<keyof Params, never, never>>' is assignable to the constraint of type 'Params', but 'Params' could be instantiated with a different subtype of constraint '{}'.
46+
47+
function fn6<T>(x: ExcludeWithDefault<T, never>) {
48+
var y: T = x;
49+
x = y;
50+
~
51+
!!! error TS2322: Type 'T' is not assignable to type 'ExcludeWithDefault<T, never, never>'.
52+
}
53+
54+
const fn7 = <Params>(
55+
params: Pick<Params, ExtractWithDefault<keyof Params, keyof Params>>,
56+
): Params => params;
57+
~~~~~~
58+
!!! error TS2322: Type 'Pick<Params, ExtractWithDefault<keyof Params, keyof Params, never>>' is not assignable to type 'Params'.
59+
!!! error TS2322: 'Pick<Params, ExtractWithDefault<keyof Params, keyof Params, never>>' is assignable to the constraint of type 'Params', but 'Params' could be instantiated with a different subtype of constraint '{}'.
60+
61+
function fn8<T>(x: ExtractWithDefault<T, T>) {
62+
var y: T = x;
63+
x = y;
64+
~
65+
!!! error TS2322: Type 'T' is not assignable to type 'ExtractWithDefault<T, T, never>'.
66+
}
67+
68+
type TemplatedConditional<TCheck, TExtends, TTrue, TFalse> = TCheck extends TExtends ? TTrue : TFalse;
69+
70+
const fn9 = <Params>(
71+
params: Pick<Params, TemplatedConditional<keyof Params, never, never, keyof Params>>,
72+
): Params => params;
73+
~~~~~~
74+
!!! error TS2322: Type 'Pick<Params, TemplatedConditional<keyof Params, never, never, keyof Params>>' is not assignable to type 'Params'.
75+
!!! error TS2322: 'Pick<Params, TemplatedConditional<keyof Params, never, never, keyof Params>>' is assignable to the constraint of type 'Params', but 'Params' could be instantiated with a different subtype of constraint '{}'.
76+
77+
function fn10<T>(x: TemplatedConditional<T, never, never, T>) {
78+
var y: T = x;
79+
x = y;
80+
~
81+
!!! error TS2322: Type 'T' is not assignable to type 'TemplatedConditional<T, never, never, T>'.
82+
}
83+
84+
const fn11 = <Params>(
85+
params: Pick<Params, TemplatedConditional<keyof Params, keyof Params, keyof Params, never>>,
86+
): Params => params;
87+
~~~~~~
88+
!!! error TS2322: Type 'Pick<Params, TemplatedConditional<keyof Params, keyof Params, keyof Params, never>>' is not assignable to type 'Params'.
89+
!!! error TS2322: 'Pick<Params, TemplatedConditional<keyof Params, keyof Params, keyof Params, never>>' is assignable to the constraint of type 'Params', but 'Params' could be instantiated with a different subtype of constraint '{}'.
90+
91+
function fn12<T>(x: TemplatedConditional<T, T, T, never>) {
92+
var y: T = x;
93+
x = y;
94+
~
95+
!!! error TS2322: Type 'T' is not assignable to type 'TemplatedConditional<T, T, T, never>'.
96+
}
97+
98+
declare var z: any;
99+
const zee = z!!!; // since x is `any`, `x extends null | undefined` should be both true and false - and thus yield `any`
100+

tests/baselines/reference/conditionalTypesSimplifyWhenTrivial.types

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -57,101 +57,101 @@ type ExcludeWithDefault<T, U, D = never> = T extends U ? D : T;
5757
>ExcludeWithDefault : ExcludeWithDefault<T, U, D>
5858

5959
const fn5 = <Params>(
60-
>fn5 : <Params>(params: Pick<Params, keyof Params>) => Params
61-
><Params>( params: Pick<Params, ExcludeWithDefault<keyof Params, never>>,): Params => params : <Params>(params: Pick<Params, keyof Params>) => Params
60+
>fn5 : <Params>(params: Pick<Params, ExcludeWithDefault<keyof Params, never, never>>) => Params
61+
><Params>( params: Pick<Params, ExcludeWithDefault<keyof Params, never>>,): Params => params : <Params>(params: Pick<Params, ExcludeWithDefault<keyof Params, never, never>>) => Params
6262

6363
params: Pick<Params, ExcludeWithDefault<keyof Params, never>>,
64-
>params : Pick<Params, keyof Params>
64+
>params : Pick<Params, ExcludeWithDefault<keyof Params, never, never>>
6565

6666
): Params => params;
67-
>params : Pick<Params, keyof Params>
67+
>params : Pick<Params, ExcludeWithDefault<keyof Params, never, never>>
6868

6969
function fn6<T>(x: ExcludeWithDefault<T, never>) {
70-
>fn6 : <T>(x: T) => void
71-
>x : T
70+
>fn6 : <T>(x: ExcludeWithDefault<T, never, never>) => void
71+
>x : ExcludeWithDefault<T, never, never>
7272

7373
var y: T = x;
7474
>y : T
75-
>x : T
75+
>x : ExcludeWithDefault<T, never, never>
7676

7777
x = y;
7878
>x = y : T
79-
>x : T
79+
>x : ExcludeWithDefault<T, never, never>
8080
>y : T
8181
}
8282

8383
const fn7 = <Params>(
84-
>fn7 : <Params>(params: Pick<Params, keyof Params>) => Params
85-
><Params>( params: Pick<Params, ExtractWithDefault<keyof Params, keyof Params>>,): Params => params : <Params>(params: Pick<Params, keyof Params>) => Params
84+
>fn7 : <Params>(params: Pick<Params, ExtractWithDefault<keyof Params, keyof Params, never>>) => Params
85+
><Params>( params: Pick<Params, ExtractWithDefault<keyof Params, keyof Params>>,): Params => params : <Params>(params: Pick<Params, ExtractWithDefault<keyof Params, keyof Params, never>>) => Params
8686

8787
params: Pick<Params, ExtractWithDefault<keyof Params, keyof Params>>,
88-
>params : Pick<Params, keyof Params>
88+
>params : Pick<Params, ExtractWithDefault<keyof Params, keyof Params, never>>
8989

9090
): Params => params;
91-
>params : Pick<Params, keyof Params>
91+
>params : Pick<Params, ExtractWithDefault<keyof Params, keyof Params, never>>
9292

9393
function fn8<T>(x: ExtractWithDefault<T, T>) {
94-
>fn8 : <T>(x: T) => void
95-
>x : T
94+
>fn8 : <T>(x: ExtractWithDefault<T, T, never>) => void
95+
>x : ExtractWithDefault<T, T, never>
9696

9797
var y: T = x;
9898
>y : T
99-
>x : T
99+
>x : ExtractWithDefault<T, T, never>
100100

101101
x = y;
102102
>x = y : T
103-
>x : T
103+
>x : ExtractWithDefault<T, T, never>
104104
>y : T
105105
}
106106

107107
type TemplatedConditional<TCheck, TExtends, TTrue, TFalse> = TCheck extends TExtends ? TTrue : TFalse;
108108
>TemplatedConditional : TemplatedConditional<TCheck, TExtends, TTrue, TFalse>
109109

110110
const fn9 = <Params>(
111-
>fn9 : <Params>(params: Pick<Params, keyof Params>) => Params
112-
><Params>( params: Pick<Params, TemplatedConditional<keyof Params, never, never, keyof Params>>,): Params => params : <Params>(params: Pick<Params, keyof Params>) => Params
111+
>fn9 : <Params>(params: Pick<Params, TemplatedConditional<keyof Params, never, never, keyof Params>>) => Params
112+
><Params>( params: Pick<Params, TemplatedConditional<keyof Params, never, never, keyof Params>>,): Params => params : <Params>(params: Pick<Params, TemplatedConditional<keyof Params, never, never, keyof Params>>) => Params
113113

114114
params: Pick<Params, TemplatedConditional<keyof Params, never, never, keyof Params>>,
115-
>params : Pick<Params, keyof Params>
115+
>params : Pick<Params, TemplatedConditional<keyof Params, never, never, keyof Params>>
116116

117117
): Params => params;
118-
>params : Pick<Params, keyof Params>
118+
>params : Pick<Params, TemplatedConditional<keyof Params, never, never, keyof Params>>
119119

120120
function fn10<T>(x: TemplatedConditional<T, never, never, T>) {
121-
>fn10 : <T>(x: T) => void
122-
>x : T
121+
>fn10 : <T>(x: TemplatedConditional<T, never, never, T>) => void
122+
>x : TemplatedConditional<T, never, never, T>
123123

124124
var y: T = x;
125125
>y : T
126-
>x : T
126+
>x : TemplatedConditional<T, never, never, T>
127127

128128
x = y;
129129
>x = y : T
130-
>x : T
130+
>x : TemplatedConditional<T, never, never, T>
131131
>y : T
132132
}
133133

134134
const fn11 = <Params>(
135-
>fn11 : <Params>(params: Pick<Params, keyof Params>) => Params
136-
><Params>( params: Pick<Params, TemplatedConditional<keyof Params, keyof Params, keyof Params, never>>,): Params => params : <Params>(params: Pick<Params, keyof Params>) => Params
135+
>fn11 : <Params>(params: Pick<Params, TemplatedConditional<keyof Params, keyof Params, keyof Params, never>>) => Params
136+
><Params>( params: Pick<Params, TemplatedConditional<keyof Params, keyof Params, keyof Params, never>>,): Params => params : <Params>(params: Pick<Params, TemplatedConditional<keyof Params, keyof Params, keyof Params, never>>) => Params
137137

138138
params: Pick<Params, TemplatedConditional<keyof Params, keyof Params, keyof Params, never>>,
139-
>params : Pick<Params, keyof Params>
139+
>params : Pick<Params, TemplatedConditional<keyof Params, keyof Params, keyof Params, never>>
140140

141141
): Params => params;
142-
>params : Pick<Params, keyof Params>
142+
>params : Pick<Params, TemplatedConditional<keyof Params, keyof Params, keyof Params, never>>
143143

144144
function fn12<T>(x: TemplatedConditional<T, T, T, never>) {
145-
>fn12 : <T>(x: T) => void
146-
>x : T
145+
>fn12 : <T>(x: TemplatedConditional<T, T, T, never>) => void
146+
>x : TemplatedConditional<T, T, T, never>
147147

148148
var y: T = x;
149149
>y : T
150-
>x : T
150+
>x : TemplatedConditional<T, T, T, never>
151151

152152
x = y;
153153
>x = y : T
154-
>x : T
154+
>x : TemplatedConditional<T, T, T, never>
155155
>y : T
156156
}
157157

tests/baselines/reference/inlinedAliasAssignableToConstraintSameAsAlias.types

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class A {
3131
>z : A[]
3232

3333
whereRelated< // Works // Type is same as A1, but is not assignable to type A
34-
>whereRelated : <RF extends RelationFields = RelationFields, N extends "x" | "y" | "z" = "x" | "y" | "z", A1 extends A = RF[N] extends A[] ? RF[N][0] : never, A2 extends A = RF[N] extends A[] ? RF[N][0] : never>() => number
34+
>whereRelated : <RF extends RelationFields = RelationFields, N extends "x" | "y" | "z" = "x" | "y" | "z", A1 extends A = RF[N] extends A[] ? RF[N][0] : never, A2 extends A = ShouldA<RF, N>>() => number
3535

3636
RF extends RelationFields = RelationFields,
3737
N extends Name = Name,

0 commit comments

Comments
 (0)