Skip to content

Commit 17080eb

Browse files
committed
Accept new baselines
1 parent eb06af1 commit 17080eb

7 files changed

+205
-2
lines changed

tests/baselines/reference/controlFlowTruthiness.js

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,33 @@ function f6() {
6767
y; // string | undefined
6868
}
6969
}
70-
70+
71+
function f7(x: {}) {
72+
if (x) {
73+
x; // {}
74+
}
75+
else {
76+
x; // {}
77+
}
78+
}
79+
80+
function f8<T>(x: T) {
81+
if (x) {
82+
x; // {}
83+
}
84+
else {
85+
x; // {}
86+
}
87+
}
88+
89+
function f9<T extends object>(x: T) {
90+
if (x) {
91+
x; // {}
92+
}
93+
else {
94+
x; // never
95+
}
96+
}
7197

7298
//// [controlFlowTruthiness.js]
7399
function f1() {
@@ -131,3 +157,27 @@ function f6() {
131157
y; // string | undefined
132158
}
133159
}
160+
function f7(x) {
161+
if (x) {
162+
x; // {}
163+
}
164+
else {
165+
x; // {}
166+
}
167+
}
168+
function f8(x) {
169+
if (x) {
170+
x; // {}
171+
}
172+
else {
173+
x; // {}
174+
}
175+
}
176+
function f9(x) {
177+
if (x) {
178+
x; // {}
179+
}
180+
else {
181+
x; // never
182+
}
183+
}

tests/baselines/reference/controlFlowTruthiness.symbols

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,3 +140,54 @@ function f6() {
140140
}
141141
}
142142

143+
function f7(x: {}) {
144+
>f7 : Symbol(f7, Decl(controlFlowTruthiness.ts, 67, 1))
145+
>x : Symbol(x, Decl(controlFlowTruthiness.ts, 69, 12))
146+
147+
if (x) {
148+
>x : Symbol(x, Decl(controlFlowTruthiness.ts, 69, 12))
149+
150+
x; // {}
151+
>x : Symbol(x, Decl(controlFlowTruthiness.ts, 69, 12))
152+
}
153+
else {
154+
x; // {}
155+
>x : Symbol(x, Decl(controlFlowTruthiness.ts, 69, 12))
156+
}
157+
}
158+
159+
function f8<T>(x: T) {
160+
>f8 : Symbol(f8, Decl(controlFlowTruthiness.ts, 76, 1))
161+
>T : Symbol(T, Decl(controlFlowTruthiness.ts, 78, 12))
162+
>x : Symbol(x, Decl(controlFlowTruthiness.ts, 78, 15))
163+
>T : Symbol(T, Decl(controlFlowTruthiness.ts, 78, 12))
164+
165+
if (x) {
166+
>x : Symbol(x, Decl(controlFlowTruthiness.ts, 78, 15))
167+
168+
x; // {}
169+
>x : Symbol(x, Decl(controlFlowTruthiness.ts, 78, 15))
170+
}
171+
else {
172+
x; // {}
173+
>x : Symbol(x, Decl(controlFlowTruthiness.ts, 78, 15))
174+
}
175+
}
176+
177+
function f9<T extends object>(x: T) {
178+
>f9 : Symbol(f9, Decl(controlFlowTruthiness.ts, 85, 1))
179+
>T : Symbol(T, Decl(controlFlowTruthiness.ts, 87, 12))
180+
>x : Symbol(x, Decl(controlFlowTruthiness.ts, 87, 30))
181+
>T : Symbol(T, Decl(controlFlowTruthiness.ts, 87, 12))
182+
183+
if (x) {
184+
>x : Symbol(x, Decl(controlFlowTruthiness.ts, 87, 30))
185+
186+
x; // {}
187+
>x : Symbol(x, Decl(controlFlowTruthiness.ts, 87, 30))
188+
}
189+
else {
190+
x; // never
191+
>x : Symbol(x, Decl(controlFlowTruthiness.ts, 87, 30))
192+
}
193+
}

tests/baselines/reference/controlFlowTruthiness.types

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,3 +157,50 @@ function f6() {
157157
}
158158
}
159159

160+
function f7(x: {}) {
161+
>f7 : (x: {}) => void
162+
>x : {}
163+
164+
if (x) {
165+
>x : {}
166+
167+
x; // {}
168+
>x : {}
169+
}
170+
else {
171+
x; // {}
172+
>x : {}
173+
}
174+
}
175+
176+
function f8<T>(x: T) {
177+
>f8 : <T>(x: T) => void
178+
>x : T
179+
180+
if (x) {
181+
>x : T
182+
183+
x; // {}
184+
>x : T
185+
}
186+
else {
187+
x; // {}
188+
>x : T
189+
}
190+
}
191+
192+
function f9<T extends object>(x: T) {
193+
>f9 : <T extends object>(x: T) => void
194+
>x : T
195+
196+
if (x) {
197+
>x : T
198+
199+
x; // {}
200+
>x : T
201+
}
202+
else {
203+
x; // never
204+
>x : never
205+
}
206+
}

tests/baselines/reference/keyofAndIndexedAccessErrors.errors.txt

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,11 @@ tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(114,5): error
6161
Type 'string' is not assignable to type 'J'.
6262
tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(117,5): error TS2322: Type 'T[K]' is not assignable to type 'U[J]'.
6363
Type 'T' is not assignable to type 'U'.
64+
tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(122,5): error TS2322: Type '42' is not assignable to type 'keyof T'.
65+
tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(123,5): error TS2322: Type '"hello"' is not assignable to type 'keyof T'.
6466

6567

66-
==== tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts (36 errors) ====
68+
==== tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts (38 errors) ====
6769
class Shape {
6870
name: string;
6971
width: number;
@@ -281,4 +283,14 @@ tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(117,5): error
281283
!!! error TS2322: Type 'T[K]' is not assignable to type 'U[J]'.
282284
!!! error TS2322: Type 'T' is not assignable to type 'U'.
283285
}
286+
287+
// The constraint of 'keyof T' is 'keyof T'
288+
function f4<T extends { [K in keyof T]: string }>(k: keyof T) {
289+
k = 42; // error
290+
~
291+
!!! error TS2322: Type '42' is not assignable to type 'keyof T'.
292+
k = "hello"; // error
293+
~
294+
!!! error TS2322: Type '"hello"' is not assignable to type 'keyof T'.
295+
}
284296

tests/baselines/reference/keyofAndIndexedAccessErrors.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,12 @@ function f3<T, K extends Extract<keyof T, string>, U extends T, J extends K>(
117117
tk = uj;
118118
uj = tk; // error
119119
}
120+
121+
// The constraint of 'keyof T' is 'keyof T'
122+
function f4<T extends { [K in keyof T]: string }>(k: keyof T) {
123+
k = 42; // error
124+
k = "hello"; // error
125+
}
120126

121127

122128
//// [keyofAndIndexedAccessErrors.js]
@@ -178,3 +184,8 @@ function f3(t, k, tk, u, j, uk, tj, uj) {
178184
tk = uj;
179185
uj = tk; // error
180186
}
187+
// The constraint of 'keyof T' is 'keyof T'
188+
function f4(k) {
189+
k = 42; // error
190+
k = "hello"; // error
191+
}

tests/baselines/reference/keyofAndIndexedAccessErrors.symbols

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,3 +412,19 @@ function f3<T, K extends Extract<keyof T, string>, U extends T, J extends K>(
412412
>tk : Symbol(tk, Decl(keyofAndIndexedAccessErrors.ts, 99, 15))
413413
}
414414

415+
// The constraint of 'keyof T' is 'keyof T'
416+
function f4<T extends { [K in keyof T]: string }>(k: keyof T) {
417+
>f4 : Symbol(f4, Decl(keyofAndIndexedAccessErrors.ts, 117, 1))
418+
>T : Symbol(T, Decl(keyofAndIndexedAccessErrors.ts, 120, 12))
419+
>K : Symbol(K, Decl(keyofAndIndexedAccessErrors.ts, 120, 25))
420+
>T : Symbol(T, Decl(keyofAndIndexedAccessErrors.ts, 120, 12))
421+
>k : Symbol(k, Decl(keyofAndIndexedAccessErrors.ts, 120, 50))
422+
>T : Symbol(T, Decl(keyofAndIndexedAccessErrors.ts, 120, 12))
423+
424+
k = 42; // error
425+
>k : Symbol(k, Decl(keyofAndIndexedAccessErrors.ts, 120, 50))
426+
427+
k = "hello"; // error
428+
>k : Symbol(k, Decl(keyofAndIndexedAccessErrors.ts, 120, 50))
429+
}
430+

tests/baselines/reference/keyofAndIndexedAccessErrors.types

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,3 +396,19 @@ function f3<T, K extends Extract<keyof T, string>, U extends T, J extends K>(
396396
>tk : T[K]
397397
}
398398

399+
// The constraint of 'keyof T' is 'keyof T'
400+
function f4<T extends { [K in keyof T]: string }>(k: keyof T) {
401+
>f4 : <T extends { [K in keyof T]: string; }>(k: keyof T) => void
402+
>k : keyof T
403+
404+
k = 42; // error
405+
>k = 42 : 42
406+
>k : keyof T
407+
>42 : 42
408+
409+
k = "hello"; // error
410+
>k = "hello" : "hello"
411+
>k : keyof T
412+
>"hello" : "hello"
413+
}
414+

0 commit comments

Comments
 (0)