Skip to content

Commit c3a9394

Browse files
committed
Accept new baselines
1 parent 77d01ab commit c3a9394

7 files changed

+35
-77
lines changed

tests/baselines/reference/keyofAndIndexedAccess.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -484,10 +484,10 @@ function onChangeGenericFunction<T>(handler: Handler<T & {preset: number}>) {
484484
function updateIds<T extends Record<K, string>, K extends string>(
485485
obj: T,
486486
idFields: K[],
487-
idMapping: { [oldId: string]: string }
487+
idMapping: Partial<Record<T[K], T[K]>>
488488
): Record<K, string> {
489489
for (const idField of idFields) {
490-
const newId = idMapping[obj[idField]];
490+
const newId: T[K] | undefined = idMapping[obj[idField]];
491491
if (newId) {
492492
obj[idField] = newId;
493493
}
@@ -1312,9 +1312,7 @@ declare type Handler<T> = {
13121312
declare function onChangeGenericFunction<T>(handler: Handler<T & {
13131313
preset: number;
13141314
}>): void;
1315-
declare function updateIds<T extends Record<K, string>, K extends string>(obj: T, idFields: K[], idMapping: {
1316-
[oldId: string]: string;
1317-
}): Record<K, string>;
1315+
declare function updateIds<T extends Record<K, string>, K extends string>(obj: T, idFields: K[], idMapping: Partial<Record<T[K], T[K]>>): Record<K, string>;
13181316
declare function updateIds2<T extends {
13191317
[x: string]: string;
13201318
}, K extends keyof T>(obj: T, key: K, stringMap: {

tests/baselines/reference/keyofAndIndexedAccess.symbols

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1767,9 +1767,14 @@ function updateIds<T extends Record<K, string>, K extends string>(
17671767
>idFields : Symbol(idFields, Decl(keyofAndIndexedAccess.ts, 483, 11))
17681768
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 482, 47))
17691769

1770-
idMapping: { [oldId: string]: string }
1770+
idMapping: Partial<Record<T[K], T[K]>>
17711771
>idMapping : Symbol(idMapping, Decl(keyofAndIndexedAccess.ts, 484, 18))
1772-
>oldId : Symbol(oldId, Decl(keyofAndIndexedAccess.ts, 485, 18))
1772+
>Partial : Symbol(Partial, Decl(lib.es5.d.ts, --, --))
1773+
>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --))
1774+
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 482, 19))
1775+
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 482, 47))
1776+
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 482, 19))
1777+
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 482, 47))
17731778

17741779
): Record<K, string> {
17751780
>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --))
@@ -1779,8 +1784,10 @@ function updateIds<T extends Record<K, string>, K extends string>(
17791784
>idField : Symbol(idField, Decl(keyofAndIndexedAccess.ts, 487, 14))
17801785
>idFields : Symbol(idFields, Decl(keyofAndIndexedAccess.ts, 483, 11))
17811786

1782-
const newId = idMapping[obj[idField]];
1787+
const newId: T[K] | undefined = idMapping[obj[idField]];
17831788
>newId : Symbol(newId, Decl(keyofAndIndexedAccess.ts, 488, 13))
1789+
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 482, 19))
1790+
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 482, 47))
17841791
>idMapping : Symbol(idMapping, Decl(keyofAndIndexedAccess.ts, 484, 18))
17851792
>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 482, 66))
17861793
>idField : Symbol(idField, Decl(keyofAndIndexedAccess.ts, 487, 14))

tests/baselines/reference/keyofAndIndexedAccess.types

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1731,40 +1731,39 @@ function onChangeGenericFunction<T>(handler: Handler<T & {preset: number}>) {
17311731
// Repro from #13285
17321732

17331733
function updateIds<T extends Record<K, string>, K extends string>(
1734-
>updateIds : <T extends Record<K, string>, K extends string>(obj: T, idFields: K[], idMapping: { [oldId: string]: string; }) => Record<K, string>
1734+
>updateIds : <T extends Record<K, string>, K extends string>(obj: T, idFields: K[], idMapping: Partial<Record<T[K], T[K]>>) => Record<K, string>
17351735

17361736
obj: T,
17371737
>obj : T
17381738

17391739
idFields: K[],
17401740
>idFields : K[]
17411741

1742-
idMapping: { [oldId: string]: string }
1743-
>idMapping : { [oldId: string]: string; }
1744-
>oldId : string
1742+
idMapping: Partial<Record<T[K], T[K]>>
1743+
>idMapping : Partial<Record<T[K], T[K]>>
17451744

17461745
): Record<K, string> {
17471746
for (const idField of idFields) {
17481747
>idField : K
17491748
>idFields : K[]
17501749

1751-
const newId = idMapping[obj[idField]];
1752-
>newId : { [oldId: string]: string; }[T[K]]
1753-
>idMapping[obj[idField]] : { [oldId: string]: string; }[T[K]]
1754-
>idMapping : { [oldId: string]: string; }
1750+
const newId: T[K] | undefined = idMapping[obj[idField]];
1751+
>newId : T[K] | undefined
1752+
>idMapping[obj[idField]] : Partial<Record<T[K], T[K]>>[T[K]]
1753+
>idMapping : Partial<Record<T[K], T[K]>>
17551754
>obj[idField] : T[K]
17561755
>obj : T
17571756
>idField : K
17581757

17591758
if (newId) {
1760-
>newId : { [oldId: string]: string; }[T[K]]
1759+
>newId : T[K] | undefined
17611760

17621761
obj[idField] = newId;
1763-
>obj[idField] = newId : { [oldId: string]: string; }[T[K]]
1762+
>obj[idField] = newId : T[K]
17641763
>obj[idField] : T[K]
17651764
>obj : T
17661765
>idField : K
1767-
>newId : { [oldId: string]: string; }[T[K]]
1766+
>newId : T[K]
17681767
}
17691768
}
17701769
return obj;

tests/baselines/reference/keyofAndIndexedAccessErrors.errors.txt

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,9 @@ 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]'.
7069

7170

72-
==== tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts (42 errors) ====
71+
==== tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts (41 errors) ====
7372
class Shape {
7473
name: string;
7574
width: number;
@@ -329,15 +328,7 @@ tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(158,9): error
329328
let x: Partial<Record<keyof T, string>>[K] = "hello";
330329
}
331330

332-
// We simplify indexed accesses applied to mapped types up to five levels deep
333-
334331
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]'.
332+
let x: Partial<Partial<Partial<Partial<Partial<Partial<Partial<Record<keyof T, string>>>>>>>>[K] = "hello";
342333
}
343334

tests/baselines/reference/keyofAndIndexedAccessErrors.js

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -149,14 +149,8 @@ function f30<T, K extends keyof T>() {
149149
let x: Partial<Record<keyof T, string>>[K] = "hello";
150150
}
151151

152-
// We simplify indexed accesses applied to mapped types up to five levels deep
153-
154152
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";
153+
let x: Partial<Partial<Partial<Partial<Partial<Partial<Partial<Record<keyof T, string>>>>>>>>[K] = "hello";
160154
}
161155

162156

@@ -235,10 +229,6 @@ function test1(t, k) {
235229
function f30() {
236230
var x = "hello";
237231
}
238-
// We simplify indexed accesses applied to mapped types up to five levels deep
239232
function f31() {
240233
var x = "hello";
241234
}
242-
function f32() {
243-
var x = "hello";
244-
}

tests/baselines/reference/keyofAndIndexedAccessErrors.symbols

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -502,40 +502,23 @@ function f30<T, K extends keyof T>() {
502502
>K : Symbol(K, Decl(keyofAndIndexedAccessErrors.ts, 146, 15))
503503
}
504504

505-
// We simplify indexed accesses applied to mapped types up to five levels deep
506-
507505
function f31<T, K extends keyof T>() {
508506
>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))
507+
>T : Symbol(T, Decl(keyofAndIndexedAccessErrors.ts, 150, 13))
508+
>K : Symbol(K, Decl(keyofAndIndexedAccessErrors.ts, 150, 15))
509+
>T : Symbol(T, Decl(keyofAndIndexedAccessErrors.ts, 150, 13))
512510

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, --, --))
511+
let x: Partial<Partial<Partial<Partial<Partial<Partial<Partial<Record<keyof T, string>>>>>>>>[K] = "hello";
512+
>x : Symbol(x, Decl(keyofAndIndexedAccessErrors.ts, 151, 7))
516513
>Partial : Symbol(Partial, Decl(lib.es5.d.ts, --, --))
517514
>Partial : Symbol(Partial, Decl(lib.es5.d.ts, --, --))
518515
>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, --, --))
533516
>Partial : Symbol(Partial, Decl(lib.es5.d.ts, --, --))
534517
>Partial : Symbol(Partial, Decl(lib.es5.d.ts, --, --))
535518
>Partial : Symbol(Partial, Decl(lib.es5.d.ts, --, --))
536519
>Partial : Symbol(Partial, Decl(lib.es5.d.ts, --, --))
537520
>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))
521+
>T : Symbol(T, Decl(keyofAndIndexedAccessErrors.ts, 150, 13))
522+
>K : Symbol(K, Decl(keyofAndIndexedAccessErrors.ts, 150, 15))
540523
}
541524

tests/baselines/reference/keyofAndIndexedAccessErrors.types

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -475,21 +475,11 @@ function f30<T, K extends keyof T>() {
475475
>"hello" : "hello"
476476
}
477477

478-
// We simplify indexed accesses applied to mapped types up to five levels deep
479-
480478
function f31<T, K extends keyof T>() {
481479
>f31 : <T, K extends keyof T>() => void
482480

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]
481+
let x: Partial<Partial<Partial<Partial<Partial<Partial<Partial<Record<keyof T, string>>>>>>>>[K] = "hello";
482+
>x : Partial<Partial<Partial<Partial<Partial<Partial<Partial<Record<keyof T, string>>>>>>>>[K]
493483
>"hello" : "hello"
494484
}
495485

0 commit comments

Comments
 (0)