Accept new baselines

This commit is contained in:
Anders Hejlsberg
2018-12-11 15:12:54 -08:00
parent 77d01ab332
commit c3a93944aa
7 changed files with 35 additions and 77 deletions

View File

@@ -484,10 +484,10 @@ function onChangeGenericFunction<T>(handler: Handler<T & {preset: number}>) {
function updateIds<T extends Record<K, string>, K extends string>(
obj: T,
idFields: K[],
idMapping: { [oldId: string]: string }
idMapping: Partial<Record<T[K], T[K]>>
): Record<K, string> {
for (const idField of idFields) {
const newId = idMapping[obj[idField]];
const newId: T[K] | undefined = idMapping[obj[idField]];
if (newId) {
obj[idField] = newId;
}
@@ -1312,9 +1312,7 @@ declare type Handler<T> = {
declare function onChangeGenericFunction<T>(handler: Handler<T & {
preset: number;
}>): void;
declare function updateIds<T extends Record<K, string>, K extends string>(obj: T, idFields: K[], idMapping: {
[oldId: string]: string;
}): Record<K, string>;
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>;
declare function updateIds2<T extends {
[x: string]: string;
}, K extends keyof T>(obj: T, key: K, stringMap: {

View File

@@ -1767,9 +1767,14 @@ function updateIds<T extends Record<K, string>, K extends string>(
>idFields : Symbol(idFields, Decl(keyofAndIndexedAccess.ts, 483, 11))
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 482, 47))
idMapping: { [oldId: string]: string }
idMapping: Partial<Record<T[K], T[K]>>
>idMapping : Symbol(idMapping, Decl(keyofAndIndexedAccess.ts, 484, 18))
>oldId : Symbol(oldId, Decl(keyofAndIndexedAccess.ts, 485, 18))
>Partial : Symbol(Partial, Decl(lib.es5.d.ts, --, --))
>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --))
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 482, 19))
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 482, 47))
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 482, 19))
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 482, 47))
): Record<K, string> {
>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --))
@@ -1779,8 +1784,10 @@ function updateIds<T extends Record<K, string>, K extends string>(
>idField : Symbol(idField, Decl(keyofAndIndexedAccess.ts, 487, 14))
>idFields : Symbol(idFields, Decl(keyofAndIndexedAccess.ts, 483, 11))
const newId = idMapping[obj[idField]];
const newId: T[K] | undefined = idMapping[obj[idField]];
>newId : Symbol(newId, Decl(keyofAndIndexedAccess.ts, 488, 13))
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 482, 19))
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 482, 47))
>idMapping : Symbol(idMapping, Decl(keyofAndIndexedAccess.ts, 484, 18))
>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 482, 66))
>idField : Symbol(idField, Decl(keyofAndIndexedAccess.ts, 487, 14))

View File

@@ -1731,7 +1731,7 @@ function onChangeGenericFunction<T>(handler: Handler<T & {preset: number}>) {
// Repro from #13285
function updateIds<T extends Record<K, string>, K extends string>(
>updateIds : <T extends Record<K, string>, K extends string>(obj: T, idFields: K[], idMapping: { [oldId: string]: string; }) => Record<K, string>
>updateIds : <T extends Record<K, string>, K extends string>(obj: T, idFields: K[], idMapping: Partial<Record<T[K], T[K]>>) => Record<K, string>
obj: T,
>obj : T
@@ -1739,32 +1739,31 @@ function updateIds<T extends Record<K, string>, K extends string>(
idFields: K[],
>idFields : K[]
idMapping: { [oldId: string]: string }
>idMapping : { [oldId: string]: string; }
>oldId : string
idMapping: Partial<Record<T[K], T[K]>>
>idMapping : Partial<Record<T[K], T[K]>>
): Record<K, string> {
for (const idField of idFields) {
>idField : K
>idFields : K[]
const newId = idMapping[obj[idField]];
>newId : { [oldId: string]: string; }[T[K]]
>idMapping[obj[idField]] : { [oldId: string]: string; }[T[K]]
>idMapping : { [oldId: string]: string; }
const newId: T[K] | undefined = idMapping[obj[idField]];
>newId : T[K] | undefined
>idMapping[obj[idField]] : Partial<Record<T[K], T[K]>>[T[K]]
>idMapping : Partial<Record<T[K], T[K]>>
>obj[idField] : T[K]
>obj : T
>idField : K
if (newId) {
>newId : { [oldId: string]: string; }[T[K]]
>newId : T[K] | undefined
obj[idField] = newId;
>obj[idField] = newId : { [oldId: string]: string; }[T[K]]
>obj[idField] = newId : T[K]
>obj[idField] : T[K]
>obj : T
>idField : K
>newId : { [oldId: string]: string; }[T[K]]
>newId : T[K]
}
}
return obj;

View File

@@ -66,10 +66,9 @@ tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(123,5): error
tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(140,5): error TS2322: Type '42' is not assignable to type 'T[K]'.
tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(141,5): error TS2322: Type '"hello"' is not assignable to type 'T[K]'.
tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(142,5): error TS2322: Type 'number[]' is not assignable to type 'T[K]'.
tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(158,9): error TS2322: Type '"hello"' is not assignable to type 'Record<keyof T, string>[K]'.
==== tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts (42 errors) ====
==== tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts (41 errors) ====
class Shape {
name: string;
width: number;
@@ -329,15 +328,7 @@ tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(158,9): error
let x: Partial<Record<keyof T, string>>[K] = "hello";
}
// We simplify indexed accesses applied to mapped types up to five levels deep
function f31<T, K extends keyof T>() {
let x: Partial<Partial<Partial<Partial<Record<keyof T, string>>>>>[K] = "hello";
}
function f32<T, K extends keyof T>() {
let x: Partial<Partial<Partial<Partial<Partial<Record<keyof T, string>>>>>>[K] = "hello";
~
!!! error TS2322: Type '"hello"' is not assignable to type 'Record<keyof T, string>[K]'.
let x: Partial<Partial<Partial<Partial<Partial<Partial<Partial<Record<keyof T, string>>>>>>>>[K] = "hello";
}

View File

@@ -149,14 +149,8 @@ function f30<T, K extends keyof T>() {
let x: Partial<Record<keyof T, string>>[K] = "hello";
}
// We simplify indexed accesses applied to mapped types up to five levels deep
function f31<T, K extends keyof T>() {
let x: Partial<Partial<Partial<Partial<Record<keyof T, string>>>>>[K] = "hello";
}
function f32<T, K extends keyof T>() {
let x: Partial<Partial<Partial<Partial<Partial<Record<keyof T, string>>>>>>[K] = "hello";
let x: Partial<Partial<Partial<Partial<Partial<Partial<Partial<Record<keyof T, string>>>>>>>>[K] = "hello";
}
@@ -235,10 +229,6 @@ function test1(t, k) {
function f30() {
var x = "hello";
}
// We simplify indexed accesses applied to mapped types up to five levels deep
function f31() {
var x = "hello";
}
function f32() {
var x = "hello";
}

View File

@@ -502,40 +502,23 @@ function f30<T, K extends keyof T>() {
>K : Symbol(K, Decl(keyofAndIndexedAccessErrors.ts, 146, 15))
}
// We simplify indexed accesses applied to mapped types up to five levels deep
function f31<T, K extends keyof T>() {
>f31 : Symbol(f31, Decl(keyofAndIndexedAccessErrors.ts, 148, 1))
>T : Symbol(T, Decl(keyofAndIndexedAccessErrors.ts, 152, 13))
>K : Symbol(K, Decl(keyofAndIndexedAccessErrors.ts, 152, 15))
>T : Symbol(T, Decl(keyofAndIndexedAccessErrors.ts, 152, 13))
>T : Symbol(T, Decl(keyofAndIndexedAccessErrors.ts, 150, 13))
>K : Symbol(K, Decl(keyofAndIndexedAccessErrors.ts, 150, 15))
>T : Symbol(T, Decl(keyofAndIndexedAccessErrors.ts, 150, 13))
let x: Partial<Partial<Partial<Partial<Record<keyof T, string>>>>>[K] = "hello";
>x : Symbol(x, Decl(keyofAndIndexedAccessErrors.ts, 153, 7))
let x: Partial<Partial<Partial<Partial<Partial<Partial<Partial<Record<keyof T, string>>>>>>>>[K] = "hello";
>x : Symbol(x, Decl(keyofAndIndexedAccessErrors.ts, 151, 7))
>Partial : Symbol(Partial, Decl(lib.es5.d.ts, --, --))
>Partial : Symbol(Partial, Decl(lib.es5.d.ts, --, --))
>Partial : Symbol(Partial, Decl(lib.es5.d.ts, --, --))
>Partial : Symbol(Partial, Decl(lib.es5.d.ts, --, --))
>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --))
>T : Symbol(T, Decl(keyofAndIndexedAccessErrors.ts, 152, 13))
>K : Symbol(K, Decl(keyofAndIndexedAccessErrors.ts, 152, 15))
}
function f32<T, K extends keyof T>() {
>f32 : Symbol(f32, Decl(keyofAndIndexedAccessErrors.ts, 154, 1))
>T : Symbol(T, Decl(keyofAndIndexedAccessErrors.ts, 156, 13))
>K : Symbol(K, Decl(keyofAndIndexedAccessErrors.ts, 156, 15))
>T : Symbol(T, Decl(keyofAndIndexedAccessErrors.ts, 156, 13))
let x: Partial<Partial<Partial<Partial<Partial<Record<keyof T, string>>>>>>[K] = "hello";
>x : Symbol(x, Decl(keyofAndIndexedAccessErrors.ts, 157, 7))
>Partial : Symbol(Partial, Decl(lib.es5.d.ts, --, --))
>Partial : Symbol(Partial, Decl(lib.es5.d.ts, --, --))
>Partial : Symbol(Partial, Decl(lib.es5.d.ts, --, --))
>Partial : Symbol(Partial, Decl(lib.es5.d.ts, --, --))
>Partial : Symbol(Partial, Decl(lib.es5.d.ts, --, --))
>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --))
>T : Symbol(T, Decl(keyofAndIndexedAccessErrors.ts, 156, 13))
>K : Symbol(K, Decl(keyofAndIndexedAccessErrors.ts, 156, 15))
>T : Symbol(T, Decl(keyofAndIndexedAccessErrors.ts, 150, 13))
>K : Symbol(K, Decl(keyofAndIndexedAccessErrors.ts, 150, 15))
}

View File

@@ -475,21 +475,11 @@ function f30<T, K extends keyof T>() {
>"hello" : "hello"
}
// We simplify indexed accesses applied to mapped types up to five levels deep
function f31<T, K extends keyof T>() {
>f31 : <T, K extends keyof T>() => void
let x: Partial<Partial<Partial<Partial<Record<keyof T, string>>>>>[K] = "hello";
>x : Partial<Partial<Partial<Partial<Record<keyof T, string>>>>>[K]
>"hello" : "hello"
}
function f32<T, K extends keyof T>() {
>f32 : <T, K extends keyof T>() => void
let x: Partial<Partial<Partial<Partial<Partial<Record<keyof T, string>>>>>>[K] = "hello";
>x : Partial<Partial<Partial<Partial<Partial<Record<keyof T, string>>>>>>[K]
let x: Partial<Partial<Partial<Partial<Partial<Partial<Partial<Record<keyof T, string>>>>>>>>[K] = "hello";
>x : Partial<Partial<Partial<Partial<Partial<Partial<Partial<Record<keyof T, string>>>>>>>>[K]
>"hello" : "hello"
}