Accept new baselines

This commit is contained in:
Anders Hejlsberg 2017-08-25 08:49:59 -07:00
parent 3d3ed04b28
commit cf998bf350
6 changed files with 154 additions and 94 deletions

View file

@ -69,7 +69,7 @@ function boxify<T>(obj: T): Boxified<T> {
result[k] = box(obj[k]);
>result[k] = box(obj[k]) : Box<T[keyof T]>
>result[k] : Box<T[keyof T]>
>result[k] : Boxified<T>[keyof T]
>result : Boxified<T>
>k : keyof T
>box(obj[k]) : Box<T[keyof T]>
@ -107,7 +107,7 @@ function unboxify<T>(obj: Boxified<T>): T {
>k : keyof T
>unbox(obj[k]) : T[keyof T]
>unbox : <T>(x: Box<T>) => T
>obj[k] : Box<T[keyof T]>
>obj[k] : Boxified<T>[keyof T]
>obj : Boxified<T>
>k : keyof T
}
@ -131,7 +131,7 @@ function assignBoxified<T>(obj: Boxified<T>, values: T) {
obj[k].value = values[k];
>obj[k].value = values[k] : T[keyof T]
>obj[k].value : T[keyof T]
>obj[k] : Box<T[keyof T]>
>obj[k] : Boxified<T>[keyof T]
>obj : Boxified<T>
>k : keyof T
>value : T[keyof T]

View file

@ -27,8 +27,8 @@ function f1<K extends string, T>(obj: { [P in K]: T }, k: K) {
>obj : { [P in K]: T; }
let x1 = obj[k1];
>x1 : T
>obj[k1] : T
>x1 : { [P in K]: T; }[K]
>obj[k1] : { [P in K]: T; }[K]
>obj : { [P in K]: T; }
>k1 : K
}
@ -37,8 +37,8 @@ function f1<K extends string, T>(obj: { [P in K]: T }, k: K) {
>obj : { [P in K]: T; }
let x2 = obj[k2];
>x2 : T
>obj[k2] : T
>x2 : { [P in K]: T; }[K]
>obj[k2] : { [P in K]: T; }[K]
>obj : { [P in K]: T; }
>k2 : K
}
@ -70,8 +70,8 @@ function f2<T>(obj: { [P in keyof T]: T[P] }, k: keyof T) {
>obj : { [P in keyof T]: T[P]; }
let x1 = obj[k1];
>x1 : T[keyof T]
>obj[k1] : T[keyof T]
>x1 : { [P in keyof T]: T[P]; }[keyof T]
>obj[k1] : { [P in keyof T]: T[P]; }[keyof T]
>obj : { [P in keyof T]: T[P]; }
>k1 : keyof T
}
@ -80,8 +80,8 @@ function f2<T>(obj: { [P in keyof T]: T[P] }, k: keyof T) {
>obj : { [P in keyof T]: T[P]; }
let x2 = obj[k2];
>x2 : T[keyof T]
>obj[k2] : T[keyof T]
>x2 : { [P in keyof T]: T[P]; }[keyof T]
>obj[k2] : { [P in keyof T]: T[P]; }[keyof T]
>obj : { [P in keyof T]: T[P]; }
>k2 : keyof T
}
@ -115,8 +115,8 @@ function f3<T, K extends keyof T>(obj: { [P in K]: T[P] }, k: K) {
>obj : { [P in K]: T[P]; }
let x1 = obj[k1];
>x1 : T[K]
>obj[k1] : T[K]
>x1 : { [P in K]: T[P]; }[K]
>obj[k1] : { [P in K]: T[P]; }[K]
>obj : { [P in K]: T[P]; }
>k1 : K
}
@ -125,8 +125,8 @@ function f3<T, K extends keyof T>(obj: { [P in K]: T[P] }, k: K) {
>obj : { [P in K]: T[P]; }
let x2 = obj[k2];
>x2 : T[K]
>obj[k2] : T[K]
>x2 : { [P in K]: T[P]; }[K]
>obj[k2] : { [P in K]: T[P]; }[K]
>obj : { [P in K]: T[P]; }
>k2 : K
}

View file

@ -2194,7 +2194,7 @@ class Form<T> {
this.childFormFactories[prop](value)
>this.childFormFactories[prop](value) : Form<T[K]>
>this.childFormFactories[prop] : (v: T[K]) => Form<T[K]>
>this.childFormFactories[prop] : { [K in keyof T]: (v: T[K]) => Form<T[K]>; }[K]
>this.childFormFactories : { [K in keyof T]: (v: T[K]) => Form<T[K]>; }
>this : this
>childFormFactories : { [K in keyof T]: (v: T[K]) => Form<T[K]>; }

View file

@ -26,17 +26,64 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(26,5): error TS2
Type 'T[string]' is not assignable to type 'U[string]'.
Type 'T' is not assignable to type 'U'.
tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(26,12): error TS2536: Type 'K' cannot be used to index type 'T'.
tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(30,5): error TS2322: Type 'T[keyof T] | undefined' is not assignable to type 'T[keyof T]'.
Type 'undefined' is not assignable to type 'T[keyof T]'.
Type 'undefined' is not assignable to type 'T[string]'.
tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(35,5): error TS2322: Type 'T[K] | undefined' is not assignable to type 'T[K]'.
Type 'undefined' is not assignable to type 'T[K]'.
Type 'undefined' is not assignable to type 'T[string]'.
tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(40,5): error TS2322: Type 'U[keyof T] | undefined' is not assignable to type 'T[keyof T]'.
Type 'undefined' is not assignable to type 'T[keyof T]'.
Type 'undefined' is not assignable to type 'T[string]'.
tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(41,5): error TS2322: Type 'T[keyof T]' is not assignable to type 'U[keyof T] | undefined'.
Type 'T[string]' is not assignable to type 'U[keyof T] | undefined'.
tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(30,5): error TS2322: Type 'Partial<T>[keyof T]' is not assignable to type 'T[keyof T]'.
Type 'T[keyof T] | undefined' is not assignable to type 'T[keyof T]'.
Type 'undefined' is not assignable to type 'T[keyof T]'.
Type 'undefined' is not assignable to type 'T[string]'.
Type 'Partial<T>[keyof T]' is not assignable to type 'T[string]'.
Type 'T[keyof T] | undefined' is not assignable to type 'T[string]'.
Type 'undefined' is not assignable to type 'T[string]'.
tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(35,5): error TS2322: Type 'Partial<T>[K]' is not assignable to type 'T[K]'.
Type 'T[K] | undefined' is not assignable to type 'T[K]'.
Type 'undefined' is not assignable to type 'T[K]'.
Type 'undefined' is not assignable to type 'T[string]'.
Type 'Partial<T>[K]' is not assignable to type 'T[string]'.
Type 'T[K] | undefined' is not assignable to type 'T[string]'.
Type 'undefined' is not assignable to type 'T[string]'.
tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(40,5): error TS2322: Type 'Partial<U>[keyof T]' is not assignable to type 'T[keyof T]'.
Type 'U[keyof T] | undefined' is not assignable to type 'T[keyof T]'.
Type 'undefined' is not assignable to type 'T[keyof T]'.
Type 'undefined' is not assignable to type 'T[string]'.
Type 'Partial<U>[keyof T]' is not assignable to type 'T[string]'.
Type 'U[keyof T] | undefined' is not assignable to type 'T[string]'.
Type 'undefined' is not assignable to type 'T[string]'.
tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(41,5): error TS2322: Type 'T[keyof T]' is not assignable to type 'Partial<U>[keyof T]'.
Type 'T[string]' is not assignable to type 'Partial<U>[keyof T]'.
Type 'T[string]' is not assignable to type 'U[keyof T] | undefined'.
Type 'T[string]' is not assignable to type 'U[keyof T]'.
Type 'T[keyof T]' is not assignable to type 'U[keyof T] | undefined'.
Type 'T[string]' is not assignable to type 'U[keyof T] | undefined'.
Type 'T[string]' is not assignable to type 'U[keyof T]'.
Type 'T[keyof T]' is not assignable to type 'U[keyof T]'.
Type 'T[string]' is not assignable to type 'U[keyof T]'.
Type 'T[string]' is not assignable to type 'U[string]'.
Type 'T[keyof T]' is not assignable to type 'U[string]'.
Type 'T[string]' is not assignable to type 'U[string]'.
Type 'T' is not assignable to type 'U'.
tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(45,5): error TS2322: Type 'Partial<U>[K]' is not assignable to type 'T[K]'.
Type 'U[K] | undefined' is not assignable to type 'T[K]'.
Type 'undefined' is not assignable to type 'T[K]'.
Type 'undefined' is not assignable to type 'T[string]'.
Type 'Partial<U>[K]' is not assignable to type 'T[string]'.
Type 'U[K] | undefined' is not assignable to type 'T[string]'.
Type 'undefined' is not assignable to type 'T[string]'.
tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(46,5): error TS2322: Type 'T[K]' is not assignable to type 'Partial<U>[K]'.
Type 'T[string]' is not assignable to type 'Partial<U>[K]'.
Type 'T[string]' is not assignable to type 'U[K] | undefined'.
Type 'T[string]' is not assignable to type 'U[K]'.
Type 'T[K]' is not assignable to type 'U[K] | undefined'.
Type 'T[string]' is not assignable to type 'U[K] | undefined'.
Type 'T[string]' is not assignable to type 'U[K]'.
Type 'T[K]' is not assignable to type 'U[K]'.
Type 'T[string]' is not assignable to type 'U[K]'.
Type 'T[string]' is not assignable to type 'U[string]'.
Type 'T[K]' is not assignable to type 'U[string]'.
Type 'T[string]' is not assignable to type 'U[string]'.
Type 'T' is not assignable to type 'U'.
tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(51,5): error TS2542: Index signature in type 'Readonly<T>' only permits reading.
tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(56,5): error TS2542: Index signature in type 'Readonly<T>' only permits reading.
tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(61,5): error TS2322: Type 'T[keyof T]' is not assignable to type 'Readonly<U>[keyof T]'.
Type 'T[string]' is not assignable to type 'Readonly<U>[keyof T]'.
Type 'T[string]' is not assignable to type 'U[keyof T]'.
Type 'T[keyof T]' is not assignable to type 'U[keyof T]'.
Type 'T[string]' is not assignable to type 'U[keyof T]'.
@ -44,11 +91,9 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(41,5): error TS2
Type 'T[keyof T]' is not assignable to type 'U[string]'.
Type 'T[string]' is not assignable to type 'U[string]'.
Type 'T' is not assignable to type 'U'.
tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(45,5): error TS2322: Type 'U[K] | undefined' is not assignable to type 'T[K]'.
Type 'undefined' is not assignable to type 'T[K]'.
Type 'undefined' is not assignable to type 'T[string]'.
tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(46,5): error TS2322: Type 'T[K]' is not assignable to type 'U[K] | undefined'.
Type 'T[string]' is not assignable to type 'U[K] | undefined'.
tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(61,5): error TS2542: Index signature in type 'Readonly<U>' only permits reading.
tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(66,5): error TS2322: Type 'T[K]' is not assignable to type 'Readonly<U>[K]'.
Type 'T[string]' is not assignable to type 'Readonly<U>[K]'.
Type 'T[string]' is not assignable to type 'U[K]'.
Type 'T[K]' is not assignable to type 'U[K]'.
Type 'T[string]' is not assignable to type 'U[K]'.
@ -56,21 +101,6 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(46,5): error TS2
Type 'T[K]' is not assignable to type 'U[string]'.
Type 'T[string]' is not assignable to type 'U[string]'.
Type 'T' is not assignable to type 'U'.
tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(51,5): error TS2542: Index signature in type 'Readonly<T>' only permits reading.
tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(56,5): error TS2542: Index signature in type 'Readonly<T>' only permits reading.
tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(61,5): error TS2322: Type 'T[keyof T]' is not assignable to type 'U[keyof T]'.
Type 'T[string]' is not assignable to type 'U[keyof T]'.
Type 'T[string]' is not assignable to type 'U[string]'.
Type 'T[keyof T]' is not assignable to type 'U[string]'.
Type 'T[string]' is not assignable to type 'U[string]'.
Type 'T' is not assignable to type 'U'.
tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(61,5): error TS2542: Index signature in type 'Readonly<U>' only permits reading.
tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(66,5): error TS2322: Type 'T[K]' is not assignable to type 'U[K]'.
Type 'T[string]' is not assignable to type 'U[K]'.
Type 'T[string]' is not assignable to type 'U[string]'.
Type 'T[K]' is not assignable to type 'U[string]'.
Type 'T[string]' is not assignable to type 'U[string]'.
Type 'T' is not assignable to type 'U'.
tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(66,5): error TS2542: Index signature in type 'Readonly<U>' only permits reading.
tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(72,5): error TS2322: Type 'Partial<T>' is not assignable to type 'T'.
tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(78,5): error TS2322: Type 'Partial<Thing>' is not assignable to type 'Partial<T>'.
@ -168,57 +198,81 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(168,5): error TS
function f10<T>(x: T, y: Partial<T>, k: keyof T) {
x[k] = y[k]; // Error
~~~~
!!! error TS2322: Type 'T[keyof T] | undefined' is not assignable to type 'T[keyof T]'.
!!! error TS2322: Type 'undefined' is not assignable to type 'T[keyof T]'.
!!! error TS2322: Type 'undefined' is not assignable to type 'T[string]'.
!!! error TS2322: Type 'Partial<T>[keyof T]' is not assignable to type 'T[keyof T]'.
!!! error TS2322: Type 'T[keyof T] | undefined' is not assignable to type 'T[keyof T]'.
!!! error TS2322: Type 'undefined' is not assignable to type 'T[keyof T]'.
!!! error TS2322: Type 'undefined' is not assignable to type 'T[string]'.
!!! error TS2322: Type 'Partial<T>[keyof T]' is not assignable to type 'T[string]'.
!!! error TS2322: Type 'T[keyof T] | undefined' is not assignable to type 'T[string]'.
!!! error TS2322: Type 'undefined' is not assignable to type 'T[string]'.
y[k] = x[k];
}
function f11<T, K extends keyof T>(x: T, y: Partial<T>, k: K) {
x[k] = y[k]; // Error
~~~~
!!! error TS2322: Type 'T[K] | undefined' is not assignable to type 'T[K]'.
!!! error TS2322: Type 'undefined' is not assignable to type 'T[K]'.
!!! error TS2322: Type 'undefined' is not assignable to type 'T[string]'.
!!! error TS2322: Type 'Partial<T>[K]' is not assignable to type 'T[K]'.
!!! error TS2322: Type 'T[K] | undefined' is not assignable to type 'T[K]'.
!!! error TS2322: Type 'undefined' is not assignable to type 'T[K]'.
!!! error TS2322: Type 'undefined' is not assignable to type 'T[string]'.
!!! error TS2322: Type 'Partial<T>[K]' is not assignable to type 'T[string]'.
!!! error TS2322: Type 'T[K] | undefined' is not assignable to type 'T[string]'.
!!! error TS2322: Type 'undefined' is not assignable to type 'T[string]'.
y[k] = x[k];
}
function f12<T, U extends T>(x: T, y: Partial<U>, k: keyof T) {
x[k] = y[k]; // Error
~~~~
!!! error TS2322: Type 'U[keyof T] | undefined' is not assignable to type 'T[keyof T]'.
!!! error TS2322: Type 'undefined' is not assignable to type 'T[keyof T]'.
!!! error TS2322: Type 'undefined' is not assignable to type 'T[string]'.
!!! error TS2322: Type 'Partial<U>[keyof T]' is not assignable to type 'T[keyof T]'.
!!! error TS2322: Type 'U[keyof T] | undefined' is not assignable to type 'T[keyof T]'.
!!! error TS2322: Type 'undefined' is not assignable to type 'T[keyof T]'.
!!! error TS2322: Type 'undefined' is not assignable to type 'T[string]'.
!!! error TS2322: Type 'Partial<U>[keyof T]' is not assignable to type 'T[string]'.
!!! error TS2322: Type 'U[keyof T] | undefined' is not assignable to type 'T[string]'.
!!! error TS2322: Type 'undefined' is not assignable to type 'T[string]'.
y[k] = x[k]; // Error
~~~~
!!! error TS2322: Type 'T[keyof T]' is not assignable to type 'U[keyof T] | undefined'.
!!! error TS2322: Type 'T[string]' is not assignable to type 'U[keyof T] | undefined'.
!!! error TS2322: Type 'T[string]' is not assignable to type 'U[keyof T]'.
!!! error TS2322: Type 'T[keyof T]' is not assignable to type 'U[keyof T]'.
!!! error TS2322: Type 'T[string]' is not assignable to type 'U[keyof T]'.
!!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'.
!!! error TS2322: Type 'T[keyof T]' is not assignable to type 'U[string]'.
!!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'.
!!! error TS2322: Type 'T' is not assignable to type 'U'.
!!! error TS2322: Type 'T[keyof T]' is not assignable to type 'Partial<U>[keyof T]'.
!!! error TS2322: Type 'T[string]' is not assignable to type 'Partial<U>[keyof T]'.
!!! error TS2322: Type 'T[string]' is not assignable to type 'U[keyof T] | undefined'.
!!! error TS2322: Type 'T[string]' is not assignable to type 'U[keyof T]'.
!!! error TS2322: Type 'T[keyof T]' is not assignable to type 'U[keyof T] | undefined'.
!!! error TS2322: Type 'T[string]' is not assignable to type 'U[keyof T] | undefined'.
!!! error TS2322: Type 'T[string]' is not assignable to type 'U[keyof T]'.
!!! error TS2322: Type 'T[keyof T]' is not assignable to type 'U[keyof T]'.
!!! error TS2322: Type 'T[string]' is not assignable to type 'U[keyof T]'.
!!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'.
!!! error TS2322: Type 'T[keyof T]' is not assignable to type 'U[string]'.
!!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'.
!!! error TS2322: Type 'T' is not assignable to type 'U'.
}
function f13<T, U extends T, K extends keyof T>(x: T, y: Partial<U>, k: K) {
x[k] = y[k]; // Error
~~~~
!!! error TS2322: Type 'U[K] | undefined' is not assignable to type 'T[K]'.
!!! error TS2322: Type 'undefined' is not assignable to type 'T[K]'.
!!! error TS2322: Type 'undefined' is not assignable to type 'T[string]'.
!!! error TS2322: Type 'Partial<U>[K]' is not assignable to type 'T[K]'.
!!! error TS2322: Type 'U[K] | undefined' is not assignable to type 'T[K]'.
!!! error TS2322: Type 'undefined' is not assignable to type 'T[K]'.
!!! error TS2322: Type 'undefined' is not assignable to type 'T[string]'.
!!! error TS2322: Type 'Partial<U>[K]' is not assignable to type 'T[string]'.
!!! error TS2322: Type 'U[K] | undefined' is not assignable to type 'T[string]'.
!!! error TS2322: Type 'undefined' is not assignable to type 'T[string]'.
y[k] = x[k]; // Error
~~~~
!!! error TS2322: Type 'T[K]' is not assignable to type 'U[K] | undefined'.
!!! error TS2322: Type 'T[string]' is not assignable to type 'U[K] | undefined'.
!!! error TS2322: Type 'T[string]' is not assignable to type 'U[K]'.
!!! error TS2322: Type 'T[K]' is not assignable to type 'U[K]'.
!!! error TS2322: Type 'T[string]' is not assignable to type 'U[K]'.
!!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'.
!!! error TS2322: Type 'T[K]' is not assignable to type 'U[string]'.
!!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'.
!!! error TS2322: Type 'T' is not assignable to type 'U'.
!!! error TS2322: Type 'T[K]' is not assignable to type 'Partial<U>[K]'.
!!! error TS2322: Type 'T[string]' is not assignable to type 'Partial<U>[K]'.
!!! error TS2322: Type 'T[string]' is not assignable to type 'U[K] | undefined'.
!!! error TS2322: Type 'T[string]' is not assignable to type 'U[K]'.
!!! error TS2322: Type 'T[K]' is not assignable to type 'U[K] | undefined'.
!!! error TS2322: Type 'T[string]' is not assignable to type 'U[K] | undefined'.
!!! error TS2322: Type 'T[string]' is not assignable to type 'U[K]'.
!!! error TS2322: Type 'T[K]' is not assignable to type 'U[K]'.
!!! error TS2322: Type 'T[string]' is not assignable to type 'U[K]'.
!!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'.
!!! error TS2322: Type 'T[K]' is not assignable to type 'U[string]'.
!!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'.
!!! error TS2322: Type 'T' is not assignable to type 'U'.
}
function f20<T>(x: T, y: Readonly<T>, k: keyof T) {
@ -239,12 +293,15 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(168,5): error TS
x[k] = y[k];
y[k] = x[k]; // Error
~~~~
!!! error TS2322: Type 'T[keyof T]' is not assignable to type 'U[keyof T]'.
!!! error TS2322: Type 'T[string]' is not assignable to type 'U[keyof T]'.
!!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'.
!!! error TS2322: Type 'T[keyof T]' is not assignable to type 'U[string]'.
!!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'.
!!! error TS2322: Type 'T' is not assignable to type 'U'.
!!! error TS2322: Type 'T[keyof T]' is not assignable to type 'Readonly<U>[keyof T]'.
!!! error TS2322: Type 'T[string]' is not assignable to type 'Readonly<U>[keyof T]'.
!!! error TS2322: Type 'T[string]' is not assignable to type 'U[keyof T]'.
!!! error TS2322: Type 'T[keyof T]' is not assignable to type 'U[keyof T]'.
!!! error TS2322: Type 'T[string]' is not assignable to type 'U[keyof T]'.
!!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'.
!!! error TS2322: Type 'T[keyof T]' is not assignable to type 'U[string]'.
!!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'.
!!! error TS2322: Type 'T' is not assignable to type 'U'.
~~~~
!!! error TS2542: Index signature in type 'Readonly<U>' only permits reading.
}
@ -253,12 +310,15 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(168,5): error TS
x[k] = y[k];
y[k] = x[k]; // Error
~~~~
!!! error TS2322: Type 'T[K]' is not assignable to type 'U[K]'.
!!! error TS2322: Type 'T[string]' is not assignable to type 'U[K]'.
!!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'.
!!! error TS2322: Type 'T[K]' is not assignable to type 'U[string]'.
!!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'.
!!! error TS2322: Type 'T' is not assignable to type 'U'.
!!! error TS2322: Type 'T[K]' is not assignable to type 'Readonly<U>[K]'.
!!! error TS2322: Type 'T[string]' is not assignable to type 'Readonly<U>[K]'.
!!! error TS2322: Type 'T[string]' is not assignable to type 'U[K]'.
!!! error TS2322: Type 'T[K]' is not assignable to type 'U[K]'.
!!! error TS2322: Type 'T[string]' is not assignable to type 'U[K]'.
!!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'.
!!! error TS2322: Type 'T[K]' is not assignable to type 'U[string]'.
!!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'.
!!! error TS2322: Type 'T' is not assignable to type 'U'.
~~~~
!!! error TS2542: Index signature in type 'Readonly<U>' only permits reading.
}

View file

@ -45,7 +45,7 @@ function boxify<T>(obj: T): Boxified<T> {
result[k] = { value: obj[k] };
>result[k] = { value: obj[k] } : { value: T[keyof T]; }
>result[k] : Box<T[keyof T]>
>result[k] : Boxified<T>[keyof T]
>result : Boxified<T>
>k : keyof T
>{ value: obj[k] } : { value: T[keyof T]; }

View file

@ -84,15 +84,15 @@ function fun<T>(item: { [P in keyof T]: T[P] }) {
>item : { [P in keyof T]: T[P]; }
const value = item[key];
>value : T[keyof T]
>item[key] : T[keyof T]
>value : { [P in keyof T]: T[P]; }[keyof T]
>item[key] : { [P in keyof T]: T[P]; }[keyof T]
>item : { [P in keyof T]: T[P]; }
>key : keyof T
if (typeof value === "string") {
>typeof value === "string" : boolean
>typeof value : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function"
>value : T[keyof T]
>value : { [P in keyof T]: T[P]; }[keyof T]
>"string" : "string"
strings.push(value);
@ -100,7 +100,7 @@ function fun<T>(item: { [P in keyof T]: T[P] }) {
>strings.push : (...items: string[]) => number
>strings : string[]
>push : (...items: string[]) => number
>value : T[keyof T] & string
>value : { [P in keyof T]: T[P]; }[keyof T] & string
}
}
}