* Create type aliases for unresolved type symbols * Accept new baselines * Update fourslash tests * Unresolved import aliases create tagged unresolved symbols * Add comments * Accept new baselines * Add fourslash tests
526 lines
23 KiB
Plaintext
526 lines
23 KiB
Plaintext
=== tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts ===
|
|
class Shape {
|
|
>Shape : Symbol(Shape, Decl(keyofAndIndexedAccessErrors.ts, 0, 0))
|
|
|
|
name: string;
|
|
>name : Symbol(Shape.name, Decl(keyofAndIndexedAccessErrors.ts, 0, 13))
|
|
|
|
width: number;
|
|
>width : Symbol(Shape.width, Decl(keyofAndIndexedAccessErrors.ts, 1, 17))
|
|
|
|
height: number;
|
|
>height : Symbol(Shape.height, Decl(keyofAndIndexedAccessErrors.ts, 2, 18))
|
|
|
|
visible: boolean;
|
|
>visible : Symbol(Shape.visible, Decl(keyofAndIndexedAccessErrors.ts, 3, 19))
|
|
}
|
|
|
|
type Dictionary<T> = { [x: string]: T };
|
|
>Dictionary : Symbol(Dictionary, Decl(keyofAndIndexedAccessErrors.ts, 5, 1))
|
|
>T : Symbol(T, Decl(keyofAndIndexedAccessErrors.ts, 7, 16))
|
|
>x : Symbol(x, Decl(keyofAndIndexedAccessErrors.ts, 7, 24))
|
|
>T : Symbol(T, Decl(keyofAndIndexedAccessErrors.ts, 7, 16))
|
|
|
|
type T00 = keyof K0; // Error
|
|
>T00 : Symbol(T00, Decl(keyofAndIndexedAccessErrors.ts, 7, 40))
|
|
>K0 : Symbol(K0)
|
|
|
|
type T01 = keyof Object;
|
|
>T01 : Symbol(T01, Decl(keyofAndIndexedAccessErrors.ts, 9, 20))
|
|
>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
|
|
|
type T02 = keyof keyof Object;
|
|
>T02 : Symbol(T02, Decl(keyofAndIndexedAccessErrors.ts, 11, 24))
|
|
>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
|
|
|
type T03 = keyof keyof keyof Object;
|
|
>T03 : Symbol(T03, Decl(keyofAndIndexedAccessErrors.ts, 12, 30))
|
|
>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
|
|
|
type T04 = keyof keyof keyof keyof Object;
|
|
>T04 : Symbol(T04, Decl(keyofAndIndexedAccessErrors.ts, 13, 36))
|
|
>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
|
|
|
type T05 = keyof keyof keyof keyof keyof Object;
|
|
>T05 : Symbol(T05, Decl(keyofAndIndexedAccessErrors.ts, 14, 42))
|
|
>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
|
|
|
type T06 = keyof keyof keyof keyof keyof keyof Object;
|
|
>T06 : Symbol(T06, Decl(keyofAndIndexedAccessErrors.ts, 15, 48))
|
|
>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
|
|
|
type T10 = Shape["name"];
|
|
>T10 : Symbol(T10, Decl(keyofAndIndexedAccessErrors.ts, 16, 54))
|
|
>Shape : Symbol(Shape, Decl(keyofAndIndexedAccessErrors.ts, 0, 0))
|
|
|
|
type T11 = Shape["foo"]; // Error
|
|
>T11 : Symbol(T11, Decl(keyofAndIndexedAccessErrors.ts, 18, 25))
|
|
>Shape : Symbol(Shape, Decl(keyofAndIndexedAccessErrors.ts, 0, 0))
|
|
|
|
type T12 = Shape["name" | "foo"]; // Error
|
|
>T12 : Symbol(T12, Decl(keyofAndIndexedAccessErrors.ts, 19, 24))
|
|
>Shape : Symbol(Shape, Decl(keyofAndIndexedAccessErrors.ts, 0, 0))
|
|
|
|
type T13 = Shape[any]; // Error
|
|
>T13 : Symbol(T13, Decl(keyofAndIndexedAccessErrors.ts, 20, 33))
|
|
>Shape : Symbol(Shape, Decl(keyofAndIndexedAccessErrors.ts, 0, 0))
|
|
|
|
type T14 = Shape[string]; // Error
|
|
>T14 : Symbol(T14, Decl(keyofAndIndexedAccessErrors.ts, 21, 22))
|
|
>Shape : Symbol(Shape, Decl(keyofAndIndexedAccessErrors.ts, 0, 0))
|
|
|
|
type T15 = Shape[number]; // Error
|
|
>T15 : Symbol(T15, Decl(keyofAndIndexedAccessErrors.ts, 22, 25))
|
|
>Shape : Symbol(Shape, Decl(keyofAndIndexedAccessErrors.ts, 0, 0))
|
|
|
|
type T16 = Shape[boolean]; // Error
|
|
>T16 : Symbol(T16, Decl(keyofAndIndexedAccessErrors.ts, 23, 25))
|
|
>Shape : Symbol(Shape, Decl(keyofAndIndexedAccessErrors.ts, 0, 0))
|
|
|
|
type T17 = Shape[void]; // Error
|
|
>T17 : Symbol(T17, Decl(keyofAndIndexedAccessErrors.ts, 24, 26))
|
|
>Shape : Symbol(Shape, Decl(keyofAndIndexedAccessErrors.ts, 0, 0))
|
|
|
|
type T18 = Shape[undefined]; // Error
|
|
>T18 : Symbol(T18, Decl(keyofAndIndexedAccessErrors.ts, 25, 23))
|
|
>Shape : Symbol(Shape, Decl(keyofAndIndexedAccessErrors.ts, 0, 0))
|
|
|
|
type T19 = Shape[{ x: string }]; // Error
|
|
>T19 : Symbol(T19, Decl(keyofAndIndexedAccessErrors.ts, 26, 28))
|
|
>Shape : Symbol(Shape, Decl(keyofAndIndexedAccessErrors.ts, 0, 0))
|
|
>x : Symbol(x, Decl(keyofAndIndexedAccessErrors.ts, 27, 18))
|
|
|
|
type T20 = Shape[string | number]; // Error
|
|
>T20 : Symbol(T20, Decl(keyofAndIndexedAccessErrors.ts, 27, 32))
|
|
>Shape : Symbol(Shape, Decl(keyofAndIndexedAccessErrors.ts, 0, 0))
|
|
|
|
type T21 = Shape[string & number];
|
|
>T21 : Symbol(T21, Decl(keyofAndIndexedAccessErrors.ts, 28, 34))
|
|
>Shape : Symbol(Shape, Decl(keyofAndIndexedAccessErrors.ts, 0, 0))
|
|
|
|
type T22 = Shape[string | boolean]; // Error
|
|
>T22 : Symbol(T22, Decl(keyofAndIndexedAccessErrors.ts, 29, 34))
|
|
>Shape : Symbol(Shape, Decl(keyofAndIndexedAccessErrors.ts, 0, 0))
|
|
|
|
type T30 = string[]["length"];
|
|
>T30 : Symbol(T30, Decl(keyofAndIndexedAccessErrors.ts, 30, 35))
|
|
|
|
type T31 = string[][number];
|
|
>T31 : Symbol(T31, Decl(keyofAndIndexedAccessErrors.ts, 32, 30))
|
|
|
|
type T32 = string[][string]; // Error
|
|
>T32 : Symbol(T32, Decl(keyofAndIndexedAccessErrors.ts, 33, 28))
|
|
|
|
type T33 = string[][boolean]; // Error
|
|
>T33 : Symbol(T33, Decl(keyofAndIndexedAccessErrors.ts, 34, 28))
|
|
|
|
type T40 = Dictionary<string>[any];
|
|
>T40 : Symbol(T40, Decl(keyofAndIndexedAccessErrors.ts, 35, 29))
|
|
>Dictionary : Symbol(Dictionary, Decl(keyofAndIndexedAccessErrors.ts, 5, 1))
|
|
|
|
type T41 = Dictionary<string>[number];
|
|
>T41 : Symbol(T41, Decl(keyofAndIndexedAccessErrors.ts, 37, 35))
|
|
>Dictionary : Symbol(Dictionary, Decl(keyofAndIndexedAccessErrors.ts, 5, 1))
|
|
|
|
type T42 = Dictionary<string>[string];
|
|
>T42 : Symbol(T42, Decl(keyofAndIndexedAccessErrors.ts, 38, 38))
|
|
>Dictionary : Symbol(Dictionary, Decl(keyofAndIndexedAccessErrors.ts, 5, 1))
|
|
|
|
type T43 = Dictionary<string>[boolean]; // Error
|
|
>T43 : Symbol(T43, Decl(keyofAndIndexedAccessErrors.ts, 39, 38))
|
|
>Dictionary : Symbol(Dictionary, Decl(keyofAndIndexedAccessErrors.ts, 5, 1))
|
|
|
|
type T50 = any[any];
|
|
>T50 : Symbol(T50, Decl(keyofAndIndexedAccessErrors.ts, 40, 39))
|
|
|
|
type T51 = any[number];
|
|
>T51 : Symbol(T51, Decl(keyofAndIndexedAccessErrors.ts, 42, 20))
|
|
|
|
type T52 = any[string];
|
|
>T52 : Symbol(T52, Decl(keyofAndIndexedAccessErrors.ts, 43, 23))
|
|
|
|
type T53 = any[boolean]; // Error
|
|
>T53 : Symbol(T53, Decl(keyofAndIndexedAccessErrors.ts, 44, 23))
|
|
|
|
type T60 = {}["toString"];
|
|
>T60 : Symbol(T60, Decl(keyofAndIndexedAccessErrors.ts, 45, 24))
|
|
|
|
type T61 = []["toString"];
|
|
>T61 : Symbol(T61, Decl(keyofAndIndexedAccessErrors.ts, 47, 26))
|
|
|
|
declare let cond: boolean;
|
|
>cond : Symbol(cond, Decl(keyofAndIndexedAccessErrors.ts, 50, 11))
|
|
|
|
function getProperty<T, K extends keyof T>(obj: T, key: K) {
|
|
>getProperty : Symbol(getProperty, Decl(keyofAndIndexedAccessErrors.ts, 50, 26))
|
|
>T : Symbol(T, Decl(keyofAndIndexedAccessErrors.ts, 52, 21))
|
|
>K : Symbol(K, Decl(keyofAndIndexedAccessErrors.ts, 52, 23))
|
|
>T : Symbol(T, Decl(keyofAndIndexedAccessErrors.ts, 52, 21))
|
|
>obj : Symbol(obj, Decl(keyofAndIndexedAccessErrors.ts, 52, 43))
|
|
>T : Symbol(T, Decl(keyofAndIndexedAccessErrors.ts, 52, 21))
|
|
>key : Symbol(key, Decl(keyofAndIndexedAccessErrors.ts, 52, 50))
|
|
>K : Symbol(K, Decl(keyofAndIndexedAccessErrors.ts, 52, 23))
|
|
|
|
return obj[key];
|
|
>obj : Symbol(obj, Decl(keyofAndIndexedAccessErrors.ts, 52, 43))
|
|
>key : Symbol(key, Decl(keyofAndIndexedAccessErrors.ts, 52, 50))
|
|
}
|
|
|
|
function setProperty<T, K extends keyof T>(obj: T, key: K, value: T[K]) {
|
|
>setProperty : Symbol(setProperty, Decl(keyofAndIndexedAccessErrors.ts, 54, 1))
|
|
>T : Symbol(T, Decl(keyofAndIndexedAccessErrors.ts, 56, 21))
|
|
>K : Symbol(K, Decl(keyofAndIndexedAccessErrors.ts, 56, 23))
|
|
>T : Symbol(T, Decl(keyofAndIndexedAccessErrors.ts, 56, 21))
|
|
>obj : Symbol(obj, Decl(keyofAndIndexedAccessErrors.ts, 56, 43))
|
|
>T : Symbol(T, Decl(keyofAndIndexedAccessErrors.ts, 56, 21))
|
|
>key : Symbol(key, Decl(keyofAndIndexedAccessErrors.ts, 56, 50))
|
|
>K : Symbol(K, Decl(keyofAndIndexedAccessErrors.ts, 56, 23))
|
|
>value : Symbol(value, Decl(keyofAndIndexedAccessErrors.ts, 56, 58))
|
|
>T : Symbol(T, Decl(keyofAndIndexedAccessErrors.ts, 56, 21))
|
|
>K : Symbol(K, Decl(keyofAndIndexedAccessErrors.ts, 56, 23))
|
|
|
|
obj[key] = value;
|
|
>obj : Symbol(obj, Decl(keyofAndIndexedAccessErrors.ts, 56, 43))
|
|
>key : Symbol(key, Decl(keyofAndIndexedAccessErrors.ts, 56, 50))
|
|
>value : Symbol(value, Decl(keyofAndIndexedAccessErrors.ts, 56, 58))
|
|
}
|
|
|
|
function f10(shape: Shape) {
|
|
>f10 : Symbol(f10, Decl(keyofAndIndexedAccessErrors.ts, 58, 1))
|
|
>shape : Symbol(shape, Decl(keyofAndIndexedAccessErrors.ts, 60, 13))
|
|
>Shape : Symbol(Shape, Decl(keyofAndIndexedAccessErrors.ts, 0, 0))
|
|
|
|
let x1 = getProperty(shape, "name");
|
|
>x1 : Symbol(x1, Decl(keyofAndIndexedAccessErrors.ts, 61, 7))
|
|
>getProperty : Symbol(getProperty, Decl(keyofAndIndexedAccessErrors.ts, 50, 26))
|
|
>shape : Symbol(shape, Decl(keyofAndIndexedAccessErrors.ts, 60, 13))
|
|
|
|
let x2 = getProperty(shape, "size"); // Error
|
|
>x2 : Symbol(x2, Decl(keyofAndIndexedAccessErrors.ts, 62, 7))
|
|
>getProperty : Symbol(getProperty, Decl(keyofAndIndexedAccessErrors.ts, 50, 26))
|
|
>shape : Symbol(shape, Decl(keyofAndIndexedAccessErrors.ts, 60, 13))
|
|
|
|
let x3 = getProperty(shape, cond ? "name" : "size"); // Error
|
|
>x3 : Symbol(x3, Decl(keyofAndIndexedAccessErrors.ts, 63, 7))
|
|
>getProperty : Symbol(getProperty, Decl(keyofAndIndexedAccessErrors.ts, 50, 26))
|
|
>shape : Symbol(shape, Decl(keyofAndIndexedAccessErrors.ts, 60, 13))
|
|
>cond : Symbol(cond, Decl(keyofAndIndexedAccessErrors.ts, 50, 11))
|
|
|
|
setProperty(shape, "name", "rectangle");
|
|
>setProperty : Symbol(setProperty, Decl(keyofAndIndexedAccessErrors.ts, 54, 1))
|
|
>shape : Symbol(shape, Decl(keyofAndIndexedAccessErrors.ts, 60, 13))
|
|
|
|
setProperty(shape, "size", 10); // Error
|
|
>setProperty : Symbol(setProperty, Decl(keyofAndIndexedAccessErrors.ts, 54, 1))
|
|
>shape : Symbol(shape, Decl(keyofAndIndexedAccessErrors.ts, 60, 13))
|
|
|
|
setProperty(shape, cond ? "name" : "size", 10); // Error
|
|
>setProperty : Symbol(setProperty, Decl(keyofAndIndexedAccessErrors.ts, 54, 1))
|
|
>shape : Symbol(shape, Decl(keyofAndIndexedAccessErrors.ts, 60, 13))
|
|
>cond : Symbol(cond, Decl(keyofAndIndexedAccessErrors.ts, 50, 11))
|
|
}
|
|
|
|
function f20<T, U>(x: T | U, y: T & U, k1: keyof (T | U), k2: keyof T & keyof U, k3: keyof (T & U), k4: keyof T | keyof U) {
|
|
>f20 : Symbol(f20, Decl(keyofAndIndexedAccessErrors.ts, 67, 1))
|
|
>T : Symbol(T, Decl(keyofAndIndexedAccessErrors.ts, 69, 13))
|
|
>U : Symbol(U, Decl(keyofAndIndexedAccessErrors.ts, 69, 15))
|
|
>x : Symbol(x, Decl(keyofAndIndexedAccessErrors.ts, 69, 19))
|
|
>T : Symbol(T, Decl(keyofAndIndexedAccessErrors.ts, 69, 13))
|
|
>U : Symbol(U, Decl(keyofAndIndexedAccessErrors.ts, 69, 15))
|
|
>y : Symbol(y, Decl(keyofAndIndexedAccessErrors.ts, 69, 28))
|
|
>T : Symbol(T, Decl(keyofAndIndexedAccessErrors.ts, 69, 13))
|
|
>U : Symbol(U, Decl(keyofAndIndexedAccessErrors.ts, 69, 15))
|
|
>k1 : Symbol(k1, Decl(keyofAndIndexedAccessErrors.ts, 69, 38))
|
|
>T : Symbol(T, Decl(keyofAndIndexedAccessErrors.ts, 69, 13))
|
|
>U : Symbol(U, Decl(keyofAndIndexedAccessErrors.ts, 69, 15))
|
|
>k2 : Symbol(k2, Decl(keyofAndIndexedAccessErrors.ts, 69, 57))
|
|
>T : Symbol(T, Decl(keyofAndIndexedAccessErrors.ts, 69, 13))
|
|
>U : Symbol(U, Decl(keyofAndIndexedAccessErrors.ts, 69, 15))
|
|
>k3 : Symbol(k3, Decl(keyofAndIndexedAccessErrors.ts, 69, 80))
|
|
>T : Symbol(T, Decl(keyofAndIndexedAccessErrors.ts, 69, 13))
|
|
>U : Symbol(U, Decl(keyofAndIndexedAccessErrors.ts, 69, 15))
|
|
>k4 : Symbol(k4, Decl(keyofAndIndexedAccessErrors.ts, 69, 99))
|
|
>T : Symbol(T, Decl(keyofAndIndexedAccessErrors.ts, 69, 13))
|
|
>U : Symbol(U, Decl(keyofAndIndexedAccessErrors.ts, 69, 15))
|
|
|
|
x[k1];
|
|
>x : Symbol(x, Decl(keyofAndIndexedAccessErrors.ts, 69, 19))
|
|
>k1 : Symbol(k1, Decl(keyofAndIndexedAccessErrors.ts, 69, 38))
|
|
|
|
x[k2];
|
|
>x : Symbol(x, Decl(keyofAndIndexedAccessErrors.ts, 69, 19))
|
|
>k2 : Symbol(k2, Decl(keyofAndIndexedAccessErrors.ts, 69, 57))
|
|
|
|
x[k3]; // Error
|
|
>x : Symbol(x, Decl(keyofAndIndexedAccessErrors.ts, 69, 19))
|
|
>k3 : Symbol(k3, Decl(keyofAndIndexedAccessErrors.ts, 69, 80))
|
|
|
|
x[k4]; // Error
|
|
>x : Symbol(x, Decl(keyofAndIndexedAccessErrors.ts, 69, 19))
|
|
>k4 : Symbol(k4, Decl(keyofAndIndexedAccessErrors.ts, 69, 99))
|
|
|
|
y[k1];
|
|
>y : Symbol(y, Decl(keyofAndIndexedAccessErrors.ts, 69, 28))
|
|
>k1 : Symbol(k1, Decl(keyofAndIndexedAccessErrors.ts, 69, 38))
|
|
|
|
y[k2];
|
|
>y : Symbol(y, Decl(keyofAndIndexedAccessErrors.ts, 69, 28))
|
|
>k2 : Symbol(k2, Decl(keyofAndIndexedAccessErrors.ts, 69, 57))
|
|
|
|
y[k3];
|
|
>y : Symbol(y, Decl(keyofAndIndexedAccessErrors.ts, 69, 28))
|
|
>k3 : Symbol(k3, Decl(keyofAndIndexedAccessErrors.ts, 69, 80))
|
|
|
|
y[k4];
|
|
>y : Symbol(y, Decl(keyofAndIndexedAccessErrors.ts, 69, 28))
|
|
>k4 : Symbol(k4, Decl(keyofAndIndexedAccessErrors.ts, 69, 99))
|
|
|
|
k1 = k2;
|
|
>k1 : Symbol(k1, Decl(keyofAndIndexedAccessErrors.ts, 69, 38))
|
|
>k2 : Symbol(k2, Decl(keyofAndIndexedAccessErrors.ts, 69, 57))
|
|
|
|
k1 = k3; // Error
|
|
>k1 : Symbol(k1, Decl(keyofAndIndexedAccessErrors.ts, 69, 38))
|
|
>k3 : Symbol(k3, Decl(keyofAndIndexedAccessErrors.ts, 69, 80))
|
|
|
|
k1 = k4; // Error
|
|
>k1 : Symbol(k1, Decl(keyofAndIndexedAccessErrors.ts, 69, 38))
|
|
>k4 : Symbol(k4, Decl(keyofAndIndexedAccessErrors.ts, 69, 99))
|
|
|
|
k2 = k1;
|
|
>k2 : Symbol(k2, Decl(keyofAndIndexedAccessErrors.ts, 69, 57))
|
|
>k1 : Symbol(k1, Decl(keyofAndIndexedAccessErrors.ts, 69, 38))
|
|
|
|
k2 = k3; // Error
|
|
>k2 : Symbol(k2, Decl(keyofAndIndexedAccessErrors.ts, 69, 57))
|
|
>k3 : Symbol(k3, Decl(keyofAndIndexedAccessErrors.ts, 69, 80))
|
|
|
|
k2 = k4; // Error
|
|
>k2 : Symbol(k2, Decl(keyofAndIndexedAccessErrors.ts, 69, 57))
|
|
>k4 : Symbol(k4, Decl(keyofAndIndexedAccessErrors.ts, 69, 99))
|
|
|
|
k3 = k1;
|
|
>k3 : Symbol(k3, Decl(keyofAndIndexedAccessErrors.ts, 69, 80))
|
|
>k1 : Symbol(k1, Decl(keyofAndIndexedAccessErrors.ts, 69, 38))
|
|
|
|
k3 = k2;
|
|
>k3 : Symbol(k3, Decl(keyofAndIndexedAccessErrors.ts, 69, 80))
|
|
>k2 : Symbol(k2, Decl(keyofAndIndexedAccessErrors.ts, 69, 57))
|
|
|
|
k3 = k4;
|
|
>k3 : Symbol(k3, Decl(keyofAndIndexedAccessErrors.ts, 69, 80))
|
|
>k4 : Symbol(k4, Decl(keyofAndIndexedAccessErrors.ts, 69, 99))
|
|
|
|
k4 = k1;
|
|
>k4 : Symbol(k4, Decl(keyofAndIndexedAccessErrors.ts, 69, 99))
|
|
>k1 : Symbol(k1, Decl(keyofAndIndexedAccessErrors.ts, 69, 38))
|
|
|
|
k4 = k2;
|
|
>k4 : Symbol(k4, Decl(keyofAndIndexedAccessErrors.ts, 69, 99))
|
|
>k2 : Symbol(k2, Decl(keyofAndIndexedAccessErrors.ts, 69, 57))
|
|
|
|
k4 = k3;
|
|
>k4 : Symbol(k4, Decl(keyofAndIndexedAccessErrors.ts, 69, 99))
|
|
>k3 : Symbol(k3, Decl(keyofAndIndexedAccessErrors.ts, 69, 80))
|
|
}
|
|
|
|
// Repro from #17166
|
|
function f3<T, K extends Extract<keyof T, string>, U extends T, J extends K>(
|
|
>f3 : Symbol(f3, Decl(keyofAndIndexedAccessErrors.ts, 95, 1))
|
|
>T : Symbol(T, Decl(keyofAndIndexedAccessErrors.ts, 98, 12))
|
|
>K : Symbol(K, Decl(keyofAndIndexedAccessErrors.ts, 98, 14))
|
|
>Extract : Symbol(Extract, Decl(lib.es5.d.ts, --, --))
|
|
>T : Symbol(T, Decl(keyofAndIndexedAccessErrors.ts, 98, 12))
|
|
>U : Symbol(U, Decl(keyofAndIndexedAccessErrors.ts, 98, 50))
|
|
>T : Symbol(T, Decl(keyofAndIndexedAccessErrors.ts, 98, 12))
|
|
>J : Symbol(J, Decl(keyofAndIndexedAccessErrors.ts, 98, 63))
|
|
>K : Symbol(K, Decl(keyofAndIndexedAccessErrors.ts, 98, 14))
|
|
|
|
t: T, k: K, tk: T[K], u: U, j: J, uk: U[K], tj: T[J], uj: U[J]): void {
|
|
>t : Symbol(t, Decl(keyofAndIndexedAccessErrors.ts, 98, 77))
|
|
>T : Symbol(T, Decl(keyofAndIndexedAccessErrors.ts, 98, 12))
|
|
>k : Symbol(k, Decl(keyofAndIndexedAccessErrors.ts, 99, 9))
|
|
>K : Symbol(K, Decl(keyofAndIndexedAccessErrors.ts, 98, 14))
|
|
>tk : Symbol(tk, Decl(keyofAndIndexedAccessErrors.ts, 99, 15))
|
|
>T : Symbol(T, Decl(keyofAndIndexedAccessErrors.ts, 98, 12))
|
|
>K : Symbol(K, Decl(keyofAndIndexedAccessErrors.ts, 98, 14))
|
|
>u : Symbol(u, Decl(keyofAndIndexedAccessErrors.ts, 99, 25))
|
|
>U : Symbol(U, Decl(keyofAndIndexedAccessErrors.ts, 98, 50))
|
|
>j : Symbol(j, Decl(keyofAndIndexedAccessErrors.ts, 99, 31))
|
|
>J : Symbol(J, Decl(keyofAndIndexedAccessErrors.ts, 98, 63))
|
|
>uk : Symbol(uk, Decl(keyofAndIndexedAccessErrors.ts, 99, 37))
|
|
>U : Symbol(U, Decl(keyofAndIndexedAccessErrors.ts, 98, 50))
|
|
>K : Symbol(K, Decl(keyofAndIndexedAccessErrors.ts, 98, 14))
|
|
>tj : Symbol(tj, Decl(keyofAndIndexedAccessErrors.ts, 99, 47))
|
|
>T : Symbol(T, Decl(keyofAndIndexedAccessErrors.ts, 98, 12))
|
|
>J : Symbol(J, Decl(keyofAndIndexedAccessErrors.ts, 98, 63))
|
|
>uj : Symbol(uj, Decl(keyofAndIndexedAccessErrors.ts, 99, 57))
|
|
>U : Symbol(U, Decl(keyofAndIndexedAccessErrors.ts, 98, 50))
|
|
>J : Symbol(J, Decl(keyofAndIndexedAccessErrors.ts, 98, 63))
|
|
|
|
for (let key in t) {
|
|
>key : Symbol(key, Decl(keyofAndIndexedAccessErrors.ts, 100, 12))
|
|
>t : Symbol(t, Decl(keyofAndIndexedAccessErrors.ts, 98, 77))
|
|
|
|
key = k // ok, K ==> keyof T
|
|
>key : Symbol(key, Decl(keyofAndIndexedAccessErrors.ts, 100, 12))
|
|
>k : Symbol(k, Decl(keyofAndIndexedAccessErrors.ts, 99, 9))
|
|
|
|
k = key // error, keyof T =/=> K
|
|
>k : Symbol(k, Decl(keyofAndIndexedAccessErrors.ts, 99, 9))
|
|
>key : Symbol(key, Decl(keyofAndIndexedAccessErrors.ts, 100, 12))
|
|
|
|
t[key] = tk; // ok, T[K] ==> T[keyof T]
|
|
>t : Symbol(t, Decl(keyofAndIndexedAccessErrors.ts, 98, 77))
|
|
>key : Symbol(key, Decl(keyofAndIndexedAccessErrors.ts, 100, 12))
|
|
>tk : Symbol(tk, Decl(keyofAndIndexedAccessErrors.ts, 99, 15))
|
|
|
|
tk = t[key]; // error, T[keyof T] =/=> T[K]
|
|
>tk : Symbol(tk, Decl(keyofAndIndexedAccessErrors.ts, 99, 15))
|
|
>t : Symbol(t, Decl(keyofAndIndexedAccessErrors.ts, 98, 77))
|
|
>key : Symbol(key, Decl(keyofAndIndexedAccessErrors.ts, 100, 12))
|
|
}
|
|
tk = uk;
|
|
>tk : Symbol(tk, Decl(keyofAndIndexedAccessErrors.ts, 99, 15))
|
|
>uk : Symbol(uk, Decl(keyofAndIndexedAccessErrors.ts, 99, 37))
|
|
|
|
uk = tk; // error
|
|
>uk : Symbol(uk, Decl(keyofAndIndexedAccessErrors.ts, 99, 37))
|
|
>tk : Symbol(tk, Decl(keyofAndIndexedAccessErrors.ts, 99, 15))
|
|
|
|
tj = uj;
|
|
>tj : Symbol(tj, Decl(keyofAndIndexedAccessErrors.ts, 99, 47))
|
|
>uj : Symbol(uj, Decl(keyofAndIndexedAccessErrors.ts, 99, 57))
|
|
|
|
uj = tj; // error
|
|
>uj : Symbol(uj, Decl(keyofAndIndexedAccessErrors.ts, 99, 57))
|
|
>tj : Symbol(tj, Decl(keyofAndIndexedAccessErrors.ts, 99, 47))
|
|
|
|
tk = tj;
|
|
>tk : Symbol(tk, Decl(keyofAndIndexedAccessErrors.ts, 99, 15))
|
|
>tj : Symbol(tj, Decl(keyofAndIndexedAccessErrors.ts, 99, 47))
|
|
|
|
tj = tk; // error
|
|
>tj : Symbol(tj, Decl(keyofAndIndexedAccessErrors.ts, 99, 47))
|
|
>tk : Symbol(tk, Decl(keyofAndIndexedAccessErrors.ts, 99, 15))
|
|
|
|
tk = uj;
|
|
>tk : Symbol(tk, Decl(keyofAndIndexedAccessErrors.ts, 99, 15))
|
|
>uj : Symbol(uj, Decl(keyofAndIndexedAccessErrors.ts, 99, 57))
|
|
|
|
uj = tk; // error
|
|
>uj : Symbol(uj, Decl(keyofAndIndexedAccessErrors.ts, 99, 57))
|
|
>tk : Symbol(tk, Decl(keyofAndIndexedAccessErrors.ts, 99, 15))
|
|
}
|
|
|
|
// The constraint of 'keyof T' is 'keyof T'
|
|
function f4<T extends { [K in keyof T]: string }>(k: keyof T) {
|
|
>f4 : Symbol(f4, Decl(keyofAndIndexedAccessErrors.ts, 117, 1))
|
|
>T : Symbol(T, Decl(keyofAndIndexedAccessErrors.ts, 120, 12))
|
|
>K : Symbol(K, Decl(keyofAndIndexedAccessErrors.ts, 120, 25))
|
|
>T : Symbol(T, Decl(keyofAndIndexedAccessErrors.ts, 120, 12))
|
|
>k : Symbol(k, Decl(keyofAndIndexedAccessErrors.ts, 120, 50))
|
|
>T : Symbol(T, Decl(keyofAndIndexedAccessErrors.ts, 120, 12))
|
|
|
|
k = 42; // error
|
|
>k : Symbol(k, Decl(keyofAndIndexedAccessErrors.ts, 120, 50))
|
|
|
|
k = "hello"; // error
|
|
>k : Symbol(k, Decl(keyofAndIndexedAccessErrors.ts, 120, 50))
|
|
}
|
|
|
|
// Repro from #27470
|
|
|
|
type UndefinedKeys<T extends Record<string, any>> = {
|
|
>UndefinedKeys : Symbol(UndefinedKeys, Decl(keyofAndIndexedAccessErrors.ts, 123, 1))
|
|
>T : Symbol(T, Decl(keyofAndIndexedAccessErrors.ts, 127, 19))
|
|
>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --))
|
|
|
|
[K in keyof T]: undefined extends T[K] ? K : never
|
|
>K : Symbol(K, Decl(keyofAndIndexedAccessErrors.ts, 128, 3))
|
|
>T : Symbol(T, Decl(keyofAndIndexedAccessErrors.ts, 127, 19))
|
|
>T : Symbol(T, Decl(keyofAndIndexedAccessErrors.ts, 127, 19))
|
|
>K : Symbol(K, Decl(keyofAndIndexedAccessErrors.ts, 128, 3))
|
|
>K : Symbol(K, Decl(keyofAndIndexedAccessErrors.ts, 128, 3))
|
|
|
|
};
|
|
|
|
type MyType = {a: string, b: string | undefined}
|
|
>MyType : Symbol(MyType, Decl(keyofAndIndexedAccessErrors.ts, 129, 2))
|
|
>a : Symbol(a, Decl(keyofAndIndexedAccessErrors.ts, 131, 15))
|
|
>b : Symbol(b, Decl(keyofAndIndexedAccessErrors.ts, 131, 25))
|
|
|
|
type Result1 = UndefinedKeys<MyType>;
|
|
>Result1 : Symbol(Result1, Decl(keyofAndIndexedAccessErrors.ts, 131, 48))
|
|
>UndefinedKeys : Symbol(UndefinedKeys, Decl(keyofAndIndexedAccessErrors.ts, 123, 1))
|
|
>MyType : Symbol(MyType, Decl(keyofAndIndexedAccessErrors.ts, 129, 2))
|
|
|
|
const a1: Result1['a'] = 'a'; // Error
|
|
>a1 : Symbol(a1, Decl(keyofAndIndexedAccessErrors.ts, 135, 5))
|
|
>Result1 : Symbol(Result1, Decl(keyofAndIndexedAccessErrors.ts, 131, 48))
|
|
|
|
const b1: Result1['b'] = 'b';
|
|
>b1 : Symbol(b1, Decl(keyofAndIndexedAccessErrors.ts, 136, 5))
|
|
>Result1 : Symbol(Result1, Decl(keyofAndIndexedAccessErrors.ts, 131, 48))
|
|
|
|
function test1<T extends Record<string, any>, K extends keyof T>(t: T, k: K) {
|
|
>test1 : Symbol(test1, Decl(keyofAndIndexedAccessErrors.ts, 136, 29))
|
|
>T : Symbol(T, Decl(keyofAndIndexedAccessErrors.ts, 138, 15))
|
|
>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --))
|
|
>K : Symbol(K, Decl(keyofAndIndexedAccessErrors.ts, 138, 45))
|
|
>T : Symbol(T, Decl(keyofAndIndexedAccessErrors.ts, 138, 15))
|
|
>t : Symbol(t, Decl(keyofAndIndexedAccessErrors.ts, 138, 65))
|
|
>T : Symbol(T, Decl(keyofAndIndexedAccessErrors.ts, 138, 15))
|
|
>k : Symbol(k, Decl(keyofAndIndexedAccessErrors.ts, 138, 70))
|
|
>K : Symbol(K, Decl(keyofAndIndexedAccessErrors.ts, 138, 45))
|
|
|
|
t[k] = 42; // Error
|
|
>t : Symbol(t, Decl(keyofAndIndexedAccessErrors.ts, 138, 65))
|
|
>k : Symbol(k, Decl(keyofAndIndexedAccessErrors.ts, 138, 70))
|
|
|
|
t[k] = "hello"; // Error
|
|
>t : Symbol(t, Decl(keyofAndIndexedAccessErrors.ts, 138, 65))
|
|
>k : Symbol(k, Decl(keyofAndIndexedAccessErrors.ts, 138, 70))
|
|
|
|
t[k] = [10, 20]; // Error
|
|
>t : Symbol(t, Decl(keyofAndIndexedAccessErrors.ts, 138, 65))
|
|
>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))
|
|
}
|
|
|
|
function f31<T, K extends keyof T>() {
|
|
>f31 : Symbol(f31, Decl(keyofAndIndexedAccessErrors.ts, 148, 1))
|
|
>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<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, --, --))
|
|
>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, 150, 13))
|
|
>K : Symbol(K, Decl(keyofAndIndexedAccessErrors.ts, 150, 15))
|
|
}
|
|
|