Skip to content

Commit 02b13a9

Browse files
committed
Accept new baselines
1 parent 2150a64 commit 02b13a9

File tree

4 files changed

+128
-1
lines changed

4 files changed

+128
-1
lines changed

tests/baselines/reference/keyofAndIndexedAccessErrors.errors.txt

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,10 @@ tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(123,5): error
6666
tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(140,5): error TS2322: Type '42' is not assignable to type 'T[K]'.
6767
tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(141,5): error TS2322: Type '"hello"' is not assignable to type 'T[K]'.
6868
tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(142,5): error TS2322: Type 'number[]' is not assignable to type 'T[K]'.
69+
tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(158,9): error TS2322: Type '"hello"' is not assignable to type 'Record<keyof T, string>[K]'.
6970

7071

71-
==== tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts (41 errors) ====
72+
==== tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts (42 errors) ====
7273
class Shape {
7374
name: string;
7475
width: number;
@@ -321,4 +322,22 @@ tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(142,5): error
321322
~~~~
322323
!!! error TS2322: Type 'number[]' is not assignable to type 'T[K]'.
323324
}
325+
326+
// Repro from #28839
327+
328+
function f30<T, K extends keyof T>() {
329+
let x: Partial<Record<keyof T, string>>[K] = "hello";
330+
}
331+
332+
// We simplify indexed accesses applied to mapped types up to five levels deep
333+
334+
function f31<T, K extends keyof T>() {
335+
let x: Partial<Partial<Partial<Partial<Record<keyof T, string>>>>>[K] = "hello";
336+
}
337+
338+
function f32<T, K extends keyof T>() {
339+
let x: Partial<Partial<Partial<Partial<Partial<Record<keyof T, string>>>>>>[K] = "hello";
340+
~
341+
!!! error TS2322: Type '"hello"' is not assignable to type 'Record<keyof T, string>[K]'.
342+
}
324343

tests/baselines/reference/keyofAndIndexedAccessErrors.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,22 @@ function test1<T extends Record<string, any>, K extends keyof T>(t: T, k: K) {
142142
t[k] = "hello"; // Error
143143
t[k] = [10, 20]; // Error
144144
}
145+
146+
// Repro from #28839
147+
148+
function f30<T, K extends keyof T>() {
149+
let x: Partial<Record<keyof T, string>>[K] = "hello";
150+
}
151+
152+
// We simplify indexed accesses applied to mapped types up to five levels deep
153+
154+
function f31<T, K extends keyof T>() {
155+
let x: Partial<Partial<Partial<Partial<Record<keyof T, string>>>>>[K] = "hello";
156+
}
157+
158+
function f32<T, K extends keyof T>() {
159+
let x: Partial<Partial<Partial<Partial<Partial<Record<keyof T, string>>>>>>[K] = "hello";
160+
}
145161

146162

147163
//// [keyofAndIndexedAccessErrors.js]
@@ -215,3 +231,14 @@ function test1(t, k) {
215231
t[k] = "hello"; // Error
216232
t[k] = [10, 20]; // Error
217233
}
234+
// Repro from #28839
235+
function f30() {
236+
var x = "hello";
237+
}
238+
// We simplify indexed accesses applied to mapped types up to five levels deep
239+
function f31() {
240+
var x = "hello";
241+
}
242+
function f32() {
243+
var x = "hello";
244+
}

tests/baselines/reference/keyofAndIndexedAccessErrors.symbols

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,3 +486,56 @@ function test1<T extends Record<string, any>, K extends keyof T>(t: T, k: K) {
486486
>k : Symbol(k, Decl(keyofAndIndexedAccessErrors.ts, 138, 70))
487487
}
488488

489+
// Repro from #28839
490+
491+
function f30<T, K extends keyof T>() {
492+
>f30 : Symbol(f30, Decl(keyofAndIndexedAccessErrors.ts, 142, 1))
493+
>T : Symbol(T, Decl(keyofAndIndexedAccessErrors.ts, 146, 13))
494+
>K : Symbol(K, Decl(keyofAndIndexedAccessErrors.ts, 146, 15))
495+
>T : Symbol(T, Decl(keyofAndIndexedAccessErrors.ts, 146, 13))
496+
497+
let x: Partial<Record<keyof T, string>>[K] = "hello";
498+
>x : Symbol(x, Decl(keyofAndIndexedAccessErrors.ts, 147, 7))
499+
>Partial : Symbol(Partial, Decl(lib.es5.d.ts, --, --))
500+
>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --))
501+
>T : Symbol(T, Decl(keyofAndIndexedAccessErrors.ts, 146, 13))
502+
>K : Symbol(K, Decl(keyofAndIndexedAccessErrors.ts, 146, 15))
503+
}
504+
505+
// We simplify indexed accesses applied to mapped types up to five levels deep
506+
507+
function f31<T, K extends keyof T>() {
508+
>f31 : Symbol(f31, Decl(keyofAndIndexedAccessErrors.ts, 148, 1))
509+
>T : Symbol(T, Decl(keyofAndIndexedAccessErrors.ts, 152, 13))
510+
>K : Symbol(K, Decl(keyofAndIndexedAccessErrors.ts, 152, 15))
511+
>T : Symbol(T, Decl(keyofAndIndexedAccessErrors.ts, 152, 13))
512+
513+
let x: Partial<Partial<Partial<Partial<Record<keyof T, string>>>>>[K] = "hello";
514+
>x : Symbol(x, Decl(keyofAndIndexedAccessErrors.ts, 153, 7))
515+
>Partial : Symbol(Partial, Decl(lib.es5.d.ts, --, --))
516+
>Partial : Symbol(Partial, Decl(lib.es5.d.ts, --, --))
517+
>Partial : Symbol(Partial, Decl(lib.es5.d.ts, --, --))
518+
>Partial : Symbol(Partial, Decl(lib.es5.d.ts, --, --))
519+
>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --))
520+
>T : Symbol(T, Decl(keyofAndIndexedAccessErrors.ts, 152, 13))
521+
>K : Symbol(K, Decl(keyofAndIndexedAccessErrors.ts, 152, 15))
522+
}
523+
524+
function f32<T, K extends keyof T>() {
525+
>f32 : Symbol(f32, Decl(keyofAndIndexedAccessErrors.ts, 154, 1))
526+
>T : Symbol(T, Decl(keyofAndIndexedAccessErrors.ts, 156, 13))
527+
>K : Symbol(K, Decl(keyofAndIndexedAccessErrors.ts, 156, 15))
528+
>T : Symbol(T, Decl(keyofAndIndexedAccessErrors.ts, 156, 13))
529+
530+
let x: Partial<Partial<Partial<Partial<Partial<Record<keyof T, string>>>>>>[K] = "hello";
531+
>x : Symbol(x, Decl(keyofAndIndexedAccessErrors.ts, 157, 7))
532+
>Partial : Symbol(Partial, Decl(lib.es5.d.ts, --, --))
533+
>Partial : Symbol(Partial, Decl(lib.es5.d.ts, --, --))
534+
>Partial : Symbol(Partial, Decl(lib.es5.d.ts, --, --))
535+
>Partial : Symbol(Partial, Decl(lib.es5.d.ts, --, --))
536+
>Partial : Symbol(Partial, Decl(lib.es5.d.ts, --, --))
537+
>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --))
538+
>T : Symbol(T, Decl(keyofAndIndexedAccessErrors.ts, 156, 13))
539+
>K : Symbol(K, Decl(keyofAndIndexedAccessErrors.ts, 156, 15))
540+
}
541+

tests/baselines/reference/keyofAndIndexedAccessErrors.types

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,3 +465,31 @@ function test1<T extends Record<string, any>, K extends keyof T>(t: T, k: K) {
465465
>20 : 20
466466
}
467467

468+
// Repro from #28839
469+
470+
function f30<T, K extends keyof T>() {
471+
>f30 : <T, K extends keyof T>() => void
472+
473+
let x: Partial<Record<keyof T, string>>[K] = "hello";
474+
>x : Partial<Record<keyof T, string>>[K]
475+
>"hello" : "hello"
476+
}
477+
478+
// We simplify indexed accesses applied to mapped types up to five levels deep
479+
480+
function f31<T, K extends keyof T>() {
481+
>f31 : <T, K extends keyof T>() => void
482+
483+
let x: Partial<Partial<Partial<Partial<Record<keyof T, string>>>>>[K] = "hello";
484+
>x : Partial<Partial<Partial<Partial<Record<keyof T, string>>>>>[K]
485+
>"hello" : "hello"
486+
}
487+
488+
function f32<T, K extends keyof T>() {
489+
>f32 : <T, K extends keyof T>() => void
490+
491+
let x: Partial<Partial<Partial<Partial<Partial<Record<keyof T, string>>>>>>[K] = "hello";
492+
>x : Partial<Partial<Partial<Partial<Partial<Record<keyof T, string>>>>>>[K]
493+
>"hello" : "hello"
494+
}
495+

0 commit comments

Comments
 (0)