Accept new baselines

This commit is contained in:
Anders Hejlsberg 2018-12-11 12:12:57 -08:00
parent 2150a64f0c
commit 02b13a916a
4 changed files with 128 additions and 1 deletions

View File

@ -66,9 +66,10 @@ 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 (41 errors) ====
==== tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts (42 errors) ====
class Shape {
name: string;
width: number;
@ -321,4 +322,22 @@ tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(142,5): error
~~~~
!!! error TS2322: Type 'number[]' is not assignable to type 'T[K]'.
}
// Repro from #28839
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";
~
!!! error TS2322: Type '"hello"' is not assignable to type 'Record<keyof T, string>[K]'.
}

View File

@ -142,6 +142,22 @@ function test1<T extends Record<string, any>, K extends keyof T>(t: T, k: K) {
t[k] = "hello"; // Error
t[k] = [10, 20]; // Error
}
// Repro from #28839
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";
}
//// [keyofAndIndexedAccessErrors.js]
@ -215,3 +231,14 @@ function test1(t, k) {
t[k] = "hello"; // Error
t[k] = [10, 20]; // Error
}
// Repro from #28839
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

@ -486,3 +486,56 @@ function test1<T extends Record<string, any>, K extends keyof T>(t: T, k: K) {
>k : Symbol(k, Decl(keyofAndIndexedAccessErrors.ts, 138, 70))
}
// Repro from #28839
function f30<T, K extends keyof T>() {
>f30 : Symbol(f30, Decl(keyofAndIndexedAccessErrors.ts, 142, 1))
>T : Symbol(T, Decl(keyofAndIndexedAccessErrors.ts, 146, 13))
>K : Symbol(K, Decl(keyofAndIndexedAccessErrors.ts, 146, 15))
>T : Symbol(T, Decl(keyofAndIndexedAccessErrors.ts, 146, 13))
let x: Partial<Record<keyof T, string>>[K] = "hello";
>x : Symbol(x, Decl(keyofAndIndexedAccessErrors.ts, 147, 7))
>Partial : Symbol(Partial, Decl(lib.es5.d.ts, --, --))
>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --))
>T : Symbol(T, Decl(keyofAndIndexedAccessErrors.ts, 146, 13))
>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))
let x: Partial<Partial<Partial<Partial<Record<keyof T, string>>>>>[K] = "hello";
>x : Symbol(x, Decl(keyofAndIndexedAccessErrors.ts, 153, 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))
}

View File

@ -465,3 +465,31 @@ function test1<T extends Record<string, any>, K extends keyof T>(t: T, k: K) {
>20 : 20
}
// Repro from #28839
function f30<T, K extends keyof T>() {
>f30 : <T, K extends keyof T>() => void
let x: Partial<Record<keyof T, string>>[K] = "hello";
>x : Partial<Record<keyof T, string>>[K]
>"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]
>"hello" : "hello"
}