Accept new baselines

This commit is contained in:
Anders Hejlsberg
2019-04-04 16:30:44 -07:00
parent 739acee1c9
commit e01fa854e2
4 changed files with 1154 additions and 0 deletions

View File

@@ -0,0 +1,200 @@
tests/cases/conformance/types/keyof/keyofAndIndexedAccess2.ts(4,5): error TS2322: Type '"x"' is not assignable to type 'number'.
tests/cases/conformance/types/keyof/keyofAndIndexedAccess2.ts(6,5): error TS2322: Type '2' is not assignable to type '0 | 1'.
tests/cases/conformance/types/keyof/keyofAndIndexedAccess2.ts(7,5): error TS2322: Type '"x"' is not assignable to type '0 | 1'.
tests/cases/conformance/types/keyof/keyofAndIndexedAccess2.ts(8,5): error TS2322: Type '1' is not assignable to type 'never'.
tests/cases/conformance/types/keyof/keyofAndIndexedAccess2.ts(9,5): error TS2322: Type '2' is not assignable to type 'never'.
tests/cases/conformance/types/keyof/keyofAndIndexedAccess2.ts(10,5): error TS2322: Type '"x"' is not assignable to type 'never'.
tests/cases/conformance/types/keyof/keyofAndIndexedAccess2.ts(14,5): error TS2739: Type '{ [key: string]: number; }' is missing the following properties from type '{ x: number; y: number; }': x, y
tests/cases/conformance/types/keyof/keyofAndIndexedAccess2.ts(15,5): error TS2322: Type 'T' is not assignable to type '{ x: number; y: number; }'.
Type '{ [key: string]: number; }' is missing the following properties from type '{ x: number; y: number; }': x, y
tests/cases/conformance/types/keyof/keyofAndIndexedAccess2.ts(18,5): error TS2322: Type '{ x: number; y: number; }' is not assignable to type 'T'.
tests/cases/conformance/types/keyof/keyofAndIndexedAccess2.ts(19,5): error TS2322: Type '{ [key: string]: number; }' is not assignable to type 'T'.
tests/cases/conformance/types/keyof/keyofAndIndexedAccess2.ts(26,7): error TS2339: Property 'x' does not exist on type 'T'.
tests/cases/conformance/types/keyof/keyofAndIndexedAccess2.ts(27,5): error TS2322: Type '1' is not assignable to type 'T[keyof T]'.
Type '1' is not assignable to type 'T[string] & T[number]'.
Type '1' is not assignable to type 'T[string]'.
tests/cases/conformance/types/keyof/keyofAndIndexedAccess2.ts(31,5): error TS2322: Type '{ [key: string]: number; }' is not assignable to type '{ [P in K]: number; }'.
tests/cases/conformance/types/keyof/keyofAndIndexedAccess2.ts(45,3): error TS7017: Element implicitly has an 'any' type because type 'Item' has no index signature.
tests/cases/conformance/types/keyof/keyofAndIndexedAccess2.ts(46,3): error TS2322: Type '123' is not assignable to type 'string & number'.
Type '123' is not assignable to type 'string'.
tests/cases/conformance/types/keyof/keyofAndIndexedAccess2.ts(47,3): error TS2322: Type '123' is not assignable to type 'T[keyof T]'.
Type '123' is not assignable to type 'T["a"] & T["b"]'.
Type '123' is not assignable to type 'T["a"]'.
Type '123' is not assignable to type 'string'.
tests/cases/conformance/types/keyof/keyofAndIndexedAccess2.ts(48,3): error TS2322: Type '123' is not assignable to type 'T[K]'.
Type '123' is not assignable to type 'T["a"] & T["b"]'.
Type '123' is not assignable to type 'T["a"]'.
tests/cases/conformance/types/keyof/keyofAndIndexedAccess2.ts(60,7): error TS2339: Property 'foo' does not exist on type 'T'.
tests/cases/conformance/types/keyof/keyofAndIndexedAccess2.ts(61,3): error TS2536: Type 'string' cannot be used to index type 'T'.
tests/cases/conformance/types/keyof/keyofAndIndexedAccess2.ts(62,3): error TS2322: Type '123' is not assignable to type 'T[keyof T]'.
Type '123' is not assignable to type 'T[string]'.
tests/cases/conformance/types/keyof/keyofAndIndexedAccess2.ts(63,3): error TS2322: Type '123' is not assignable to type 'T[K]'.
Type '123' is not assignable to type 'T[string]'.
tests/cases/conformance/types/keyof/keyofAndIndexedAccess2.ts(103,5): error TS2322: Type '123' is not assignable to type 'Type[K]'.
Type '123' is not assignable to type '123 & "some string"'.
Type '123' is not assignable to type '"some string"'.
==== tests/cases/conformance/types/keyof/keyofAndIndexedAccess2.ts (22 errors) ====
function f1(obj: { a: number, b: 0 | 1, c: string }, k0: 'a', k1: 'a' | 'b', k2: 'a' | 'b' | 'c') {
obj[k0] = 1;
obj[k0] = 2;
obj[k0] = 'x'; // Error
~~~~~~~
!!! error TS2322: Type '"x"' is not assignable to type 'number'.
obj[k1] = 1;
obj[k1] = 2; // Error
~~~~~~~
!!! error TS2322: Type '2' is not assignable to type '0 | 1'.
obj[k1] = 'x'; // Error
~~~~~~~
!!! error TS2322: Type '"x"' is not assignable to type '0 | 1'.
obj[k2] = 1; // Error
~~~~~~~
!!! error TS2322: Type '1' is not assignable to type 'never'.
obj[k2] = 2; // Error
~~~~~~~
!!! error TS2322: Type '2' is not assignable to type 'never'.
obj[k2] = 'x'; // Error
~~~~~~~
!!! error TS2322: Type '"x"' is not assignable to type 'never'.
}
function f2<T extends { [key: string]: number }>(a: { x: number, y: number }, b: { [key: string]: number }, c: T, k: keyof T) {
a = b; // Error, index signature in source doesn't imply properties are present
~
!!! error TS2739: Type '{ [key: string]: number; }' is missing the following properties from type '{ x: number; y: number; }': x, y
a = c; // Error, index signature in source doesn't imply properties are present
~
!!! error TS2322: Type 'T' is not assignable to type '{ x: number; y: number; }'.
!!! error TS2322: Type '{ [key: string]: number; }' is missing the following properties from type '{ x: number; y: number; }': x, y
b = a;
b = c;
c = a; // Error, constraint on target doesn't imply any properties or signatures
~
!!! error TS2322: Type '{ x: number; y: number; }' is not assignable to type 'T'.
c = b; // Error, constraint on target doesn't imply any properties or signatures
~
!!! error TS2322: Type '{ [key: string]: number; }' is not assignable to type 'T'.
a.x;
b.x;
c.x;
c[k];
a.x = 1;
b.x = 1;
c.x = 1; // Error, cannot write to index signature through constraint
~
!!! error TS2339: Property 'x' does not exist on type 'T'.
c[k] = 1; // Error, cannot write to index signature through constraint
~~~~
!!! error TS2322: Type '1' is not assignable to type 'T[keyof T]'.
!!! error TS2322: Type '1' is not assignable to type 'T[string] & T[number]'.
!!! error TS2322: Type '1' is not assignable to type 'T[string]'.
}
function f3<K extends string>(a: { [P in K]: number }, b: { [key: string]: number }, k: K) {
a = b; // Error, index signature doesn't imply properties are present
~
!!! error TS2322: Type '{ [key: string]: number; }' is not assignable to type '{ [P in K]: number; }'.
b = a;
a[k];
a[k] = 1;
}
function f4<K extends string>(a: { [key: string]: number }[K], b: number) {
a = b;
b = a;
}
type Item = { a: string, b: number };
function f10<T extends Item, K extends keyof T>(obj: T, k1: string, k2: keyof Item, k3: keyof T, k4: K) {
obj[k1] = 123; // Error
~~~~~~~
!!! error TS7017: Element implicitly has an 'any' type because type 'Item' has no index signature.
obj[k2] = 123; // Error
~~~~~~~
!!! error TS2322: Type '123' is not assignable to type 'string & number'.
!!! error TS2322: Type '123' is not assignable to type 'string'.
obj[k3] = 123; // Error
~~~~~~~
!!! error TS2322: Type '123' is not assignable to type 'T[keyof T]'.
!!! error TS2322: Type '123' is not assignable to type 'T["a"] & T["b"]'.
!!! error TS2322: Type '123' is not assignable to type 'T["a"]'.
!!! error TS2322: Type '123' is not assignable to type 'string'.
obj[k4] = 123; // Error
~~~~~~~
!!! error TS2322: Type '123' is not assignable to type 'T[K]'.
!!! error TS2322: Type '123' is not assignable to type 'T["a"] & T["b"]'.
!!! error TS2322: Type '123' is not assignable to type 'T["a"]'.
}
type Dict = Record<string, number>;
function f11<K extends keyof Dict>(obj: Dict, k1: keyof Dict, k2: K) {
obj.foo = 123;
obj[k1] = 123;
obj[k2] = 123;
}
function f12<T extends Readonly<Dict>, K extends keyof T>(obj: T, k1: keyof Dict, k2: keyof T, k3: K) {
obj.foo = 123; // Error
~~~
!!! error TS2339: Property 'foo' does not exist on type 'T'.
obj[k1] = 123; // Error
~~~~~~~
!!! error TS2536: Type 'string' cannot be used to index type 'T'.
obj[k2] = 123; // Error
~~~~~~~
!!! error TS2322: Type '123' is not assignable to type 'T[keyof T]'.
!!! error TS2322: Type '123' is not assignable to type 'T[string]'.
obj[k3] = 123; // Error
~~~~~~~
!!! error TS2322: Type '123' is not assignable to type 'T[K]'.
!!! error TS2322: Type '123' is not assignable to type 'T[string]'.
}
// Repro from #27895
export interface Entity {
id: number | string;
}
export type IdOf<E extends Entity> = E['id'];
export interface EntityState<E extends Entity> {
ids: IdOf<E>[];
entities: { [key: string]: E, [key: number]: E };
}
export function getAllEntities<E extends Entity>(state: EntityState<E>): E[] {
const { ids, entities } = state;
return ids.map(id => entities[id]);
}
export function getEntity<E extends Entity>(id: IdOf<E>, state: EntityState<E>): E | undefined {
const { ids, entities } = state;
if (!ids.includes(id)) {
return undefined;
}
return entities[id];
}
// Repro from #30603
interface Type {
a: 123;
b: "some string";
}
function get123<K extends keyof Type>(): Type[K] {
return 123; // Error
~~~~~~~~~~~
!!! error TS2322: Type '123' is not assignable to type 'Type[K]'.
!!! error TS2322: Type '123' is not assignable to type '123 & "some string"'.
!!! error TS2322: Type '123' is not assignable to type '"some string"'.
}

View File

@@ -0,0 +1,176 @@
//// [keyofAndIndexedAccess2.ts]
function f1(obj: { a: number, b: 0 | 1, c: string }, k0: 'a', k1: 'a' | 'b', k2: 'a' | 'b' | 'c') {
obj[k0] = 1;
obj[k0] = 2;
obj[k0] = 'x'; // Error
obj[k1] = 1;
obj[k1] = 2; // Error
obj[k1] = 'x'; // Error
obj[k2] = 1; // Error
obj[k2] = 2; // Error
obj[k2] = 'x'; // Error
}
function f2<T extends { [key: string]: number }>(a: { x: number, y: number }, b: { [key: string]: number }, c: T, k: keyof T) {
a = b; // Error, index signature in source doesn't imply properties are present
a = c; // Error, index signature in source doesn't imply properties are present
b = a;
b = c;
c = a; // Error, constraint on target doesn't imply any properties or signatures
c = b; // Error, constraint on target doesn't imply any properties or signatures
a.x;
b.x;
c.x;
c[k];
a.x = 1;
b.x = 1;
c.x = 1; // Error, cannot write to index signature through constraint
c[k] = 1; // Error, cannot write to index signature through constraint
}
function f3<K extends string>(a: { [P in K]: number }, b: { [key: string]: number }, k: K) {
a = b; // Error, index signature doesn't imply properties are present
b = a;
a[k];
a[k] = 1;
}
function f4<K extends string>(a: { [key: string]: number }[K], b: number) {
a = b;
b = a;
}
type Item = { a: string, b: number };
function f10<T extends Item, K extends keyof T>(obj: T, k1: string, k2: keyof Item, k3: keyof T, k4: K) {
obj[k1] = 123; // Error
obj[k2] = 123; // Error
obj[k3] = 123; // Error
obj[k4] = 123; // Error
}
type Dict = Record<string, number>;
function f11<K extends keyof Dict>(obj: Dict, k1: keyof Dict, k2: K) {
obj.foo = 123;
obj[k1] = 123;
obj[k2] = 123;
}
function f12<T extends Readonly<Dict>, K extends keyof T>(obj: T, k1: keyof Dict, k2: keyof T, k3: K) {
obj.foo = 123; // Error
obj[k1] = 123; // Error
obj[k2] = 123; // Error
obj[k3] = 123; // Error
}
// Repro from #27895
export interface Entity {
id: number | string;
}
export type IdOf<E extends Entity> = E['id'];
export interface EntityState<E extends Entity> {
ids: IdOf<E>[];
entities: { [key: string]: E, [key: number]: E };
}
export function getAllEntities<E extends Entity>(state: EntityState<E>): E[] {
const { ids, entities } = state;
return ids.map(id => entities[id]);
}
export function getEntity<E extends Entity>(id: IdOf<E>, state: EntityState<E>): E | undefined {
const { ids, entities } = state;
if (!ids.includes(id)) {
return undefined;
}
return entities[id];
}
// Repro from #30603
interface Type {
a: 123;
b: "some string";
}
function get123<K extends keyof Type>(): Type[K] {
return 123; // Error
}
//// [keyofAndIndexedAccess2.js]
function f1(obj, k0, k1, k2) {
obj[k0] = 1;
obj[k0] = 2;
obj[k0] = 'x'; // Error
obj[k1] = 1;
obj[k1] = 2; // Error
obj[k1] = 'x'; // Error
obj[k2] = 1; // Error
obj[k2] = 2; // Error
obj[k2] = 'x'; // Error
}
function f2(a, b, c, k) {
a = b; // Error, index signature in source doesn't imply properties are present
a = c; // Error, index signature in source doesn't imply properties are present
b = a;
b = c;
c = a; // Error, constraint on target doesn't imply any properties or signatures
c = b; // Error, constraint on target doesn't imply any properties or signatures
a.x;
b.x;
c.x;
c[k];
a.x = 1;
b.x = 1;
c.x = 1; // Error, cannot write to index signature through constraint
c[k] = 1; // Error, cannot write to index signature through constraint
}
function f3(a, b, k) {
a = b; // Error, index signature doesn't imply properties are present
b = a;
a[k];
a[k] = 1;
}
function f4(a, b) {
a = b;
b = a;
}
function f10(obj, k1, k2, k3, k4) {
obj[k1] = 123; // Error
obj[k2] = 123; // Error
obj[k3] = 123; // Error
obj[k4] = 123; // Error
}
function f11(obj, k1, k2) {
obj.foo = 123;
obj[k1] = 123;
obj[k2] = 123;
}
function f12(obj, k1, k2, k3) {
obj.foo = 123; // Error
obj[k1] = 123; // Error
obj[k2] = 123; // Error
obj[k3] = 123; // Error
}
export function getAllEntities(state) {
const { ids, entities } = state;
return ids.map(id => entities[id]);
}
export function getEntity(id, state) {
const { ids, entities } = state;
if (!ids.includes(id)) {
return undefined;
}
return entities[id];
}
function get123() {
return 123; // Error
}

View File

@@ -0,0 +1,370 @@
=== tests/cases/conformance/types/keyof/keyofAndIndexedAccess2.ts ===
function f1(obj: { a: number, b: 0 | 1, c: string }, k0: 'a', k1: 'a' | 'b', k2: 'a' | 'b' | 'c') {
>f1 : Symbol(f1, Decl(keyofAndIndexedAccess2.ts, 0, 0))
>obj : Symbol(obj, Decl(keyofAndIndexedAccess2.ts, 0, 12))
>a : Symbol(a, Decl(keyofAndIndexedAccess2.ts, 0, 18))
>b : Symbol(b, Decl(keyofAndIndexedAccess2.ts, 0, 29))
>c : Symbol(c, Decl(keyofAndIndexedAccess2.ts, 0, 39))
>k0 : Symbol(k0, Decl(keyofAndIndexedAccess2.ts, 0, 52))
>k1 : Symbol(k1, Decl(keyofAndIndexedAccess2.ts, 0, 61))
>k2 : Symbol(k2, Decl(keyofAndIndexedAccess2.ts, 0, 76))
obj[k0] = 1;
>obj : Symbol(obj, Decl(keyofAndIndexedAccess2.ts, 0, 12))
>k0 : Symbol(k0, Decl(keyofAndIndexedAccess2.ts, 0, 52))
obj[k0] = 2;
>obj : Symbol(obj, Decl(keyofAndIndexedAccess2.ts, 0, 12))
>k0 : Symbol(k0, Decl(keyofAndIndexedAccess2.ts, 0, 52))
obj[k0] = 'x'; // Error
>obj : Symbol(obj, Decl(keyofAndIndexedAccess2.ts, 0, 12))
>k0 : Symbol(k0, Decl(keyofAndIndexedAccess2.ts, 0, 52))
obj[k1] = 1;
>obj : Symbol(obj, Decl(keyofAndIndexedAccess2.ts, 0, 12))
>k1 : Symbol(k1, Decl(keyofAndIndexedAccess2.ts, 0, 61))
obj[k1] = 2; // Error
>obj : Symbol(obj, Decl(keyofAndIndexedAccess2.ts, 0, 12))
>k1 : Symbol(k1, Decl(keyofAndIndexedAccess2.ts, 0, 61))
obj[k1] = 'x'; // Error
>obj : Symbol(obj, Decl(keyofAndIndexedAccess2.ts, 0, 12))
>k1 : Symbol(k1, Decl(keyofAndIndexedAccess2.ts, 0, 61))
obj[k2] = 1; // Error
>obj : Symbol(obj, Decl(keyofAndIndexedAccess2.ts, 0, 12))
>k2 : Symbol(k2, Decl(keyofAndIndexedAccess2.ts, 0, 76))
obj[k2] = 2; // Error
>obj : Symbol(obj, Decl(keyofAndIndexedAccess2.ts, 0, 12))
>k2 : Symbol(k2, Decl(keyofAndIndexedAccess2.ts, 0, 76))
obj[k2] = 'x'; // Error
>obj : Symbol(obj, Decl(keyofAndIndexedAccess2.ts, 0, 12))
>k2 : Symbol(k2, Decl(keyofAndIndexedAccess2.ts, 0, 76))
}
function f2<T extends { [key: string]: number }>(a: { x: number, y: number }, b: { [key: string]: number }, c: T, k: keyof T) {
>f2 : Symbol(f2, Decl(keyofAndIndexedAccess2.ts, 10, 1))
>T : Symbol(T, Decl(keyofAndIndexedAccess2.ts, 12, 12))
>key : Symbol(key, Decl(keyofAndIndexedAccess2.ts, 12, 25))
>a : Symbol(a, Decl(keyofAndIndexedAccess2.ts, 12, 49))
>x : Symbol(x, Decl(keyofAndIndexedAccess2.ts, 12, 53))
>y : Symbol(y, Decl(keyofAndIndexedAccess2.ts, 12, 64))
>b : Symbol(b, Decl(keyofAndIndexedAccess2.ts, 12, 77))
>key : Symbol(key, Decl(keyofAndIndexedAccess2.ts, 12, 84))
>c : Symbol(c, Decl(keyofAndIndexedAccess2.ts, 12, 107))
>T : Symbol(T, Decl(keyofAndIndexedAccess2.ts, 12, 12))
>k : Symbol(k, Decl(keyofAndIndexedAccess2.ts, 12, 113))
>T : Symbol(T, Decl(keyofAndIndexedAccess2.ts, 12, 12))
a = b; // Error, index signature in source doesn't imply properties are present
>a : Symbol(a, Decl(keyofAndIndexedAccess2.ts, 12, 49))
>b : Symbol(b, Decl(keyofAndIndexedAccess2.ts, 12, 77))
a = c; // Error, index signature in source doesn't imply properties are present
>a : Symbol(a, Decl(keyofAndIndexedAccess2.ts, 12, 49))
>c : Symbol(c, Decl(keyofAndIndexedAccess2.ts, 12, 107))
b = a;
>b : Symbol(b, Decl(keyofAndIndexedAccess2.ts, 12, 77))
>a : Symbol(a, Decl(keyofAndIndexedAccess2.ts, 12, 49))
b = c;
>b : Symbol(b, Decl(keyofAndIndexedAccess2.ts, 12, 77))
>c : Symbol(c, Decl(keyofAndIndexedAccess2.ts, 12, 107))
c = a; // Error, constraint on target doesn't imply any properties or signatures
>c : Symbol(c, Decl(keyofAndIndexedAccess2.ts, 12, 107))
>a : Symbol(a, Decl(keyofAndIndexedAccess2.ts, 12, 49))
c = b; // Error, constraint on target doesn't imply any properties or signatures
>c : Symbol(c, Decl(keyofAndIndexedAccess2.ts, 12, 107))
>b : Symbol(b, Decl(keyofAndIndexedAccess2.ts, 12, 77))
a.x;
>a.x : Symbol(x, Decl(keyofAndIndexedAccess2.ts, 12, 53))
>a : Symbol(a, Decl(keyofAndIndexedAccess2.ts, 12, 49))
>x : Symbol(x, Decl(keyofAndIndexedAccess2.ts, 12, 53))
b.x;
>b : Symbol(b, Decl(keyofAndIndexedAccess2.ts, 12, 77))
c.x;
>c : Symbol(c, Decl(keyofAndIndexedAccess2.ts, 12, 107))
c[k];
>c : Symbol(c, Decl(keyofAndIndexedAccess2.ts, 12, 107))
>k : Symbol(k, Decl(keyofAndIndexedAccess2.ts, 12, 113))
a.x = 1;
>a.x : Symbol(x, Decl(keyofAndIndexedAccess2.ts, 12, 53))
>a : Symbol(a, Decl(keyofAndIndexedAccess2.ts, 12, 49))
>x : Symbol(x, Decl(keyofAndIndexedAccess2.ts, 12, 53))
b.x = 1;
>b : Symbol(b, Decl(keyofAndIndexedAccess2.ts, 12, 77))
c.x = 1; // Error, cannot write to index signature through constraint
>c : Symbol(c, Decl(keyofAndIndexedAccess2.ts, 12, 107))
c[k] = 1; // Error, cannot write to index signature through constraint
>c : Symbol(c, Decl(keyofAndIndexedAccess2.ts, 12, 107))
>k : Symbol(k, Decl(keyofAndIndexedAccess2.ts, 12, 113))
}
function f3<K extends string>(a: { [P in K]: number }, b: { [key: string]: number }, k: K) {
>f3 : Symbol(f3, Decl(keyofAndIndexedAccess2.ts, 27, 1))
>K : Symbol(K, Decl(keyofAndIndexedAccess2.ts, 29, 12))
>a : Symbol(a, Decl(keyofAndIndexedAccess2.ts, 29, 30))
>P : Symbol(P, Decl(keyofAndIndexedAccess2.ts, 29, 36))
>K : Symbol(K, Decl(keyofAndIndexedAccess2.ts, 29, 12))
>b : Symbol(b, Decl(keyofAndIndexedAccess2.ts, 29, 54))
>key : Symbol(key, Decl(keyofAndIndexedAccess2.ts, 29, 61))
>k : Symbol(k, Decl(keyofAndIndexedAccess2.ts, 29, 84))
>K : Symbol(K, Decl(keyofAndIndexedAccess2.ts, 29, 12))
a = b; // Error, index signature doesn't imply properties are present
>a : Symbol(a, Decl(keyofAndIndexedAccess2.ts, 29, 30))
>b : Symbol(b, Decl(keyofAndIndexedAccess2.ts, 29, 54))
b = a;
>b : Symbol(b, Decl(keyofAndIndexedAccess2.ts, 29, 54))
>a : Symbol(a, Decl(keyofAndIndexedAccess2.ts, 29, 30))
a[k];
>a : Symbol(a, Decl(keyofAndIndexedAccess2.ts, 29, 30))
>k : Symbol(k, Decl(keyofAndIndexedAccess2.ts, 29, 84))
a[k] = 1;
>a : Symbol(a, Decl(keyofAndIndexedAccess2.ts, 29, 30))
>k : Symbol(k, Decl(keyofAndIndexedAccess2.ts, 29, 84))
}
function f4<K extends string>(a: { [key: string]: number }[K], b: number) {
>f4 : Symbol(f4, Decl(keyofAndIndexedAccess2.ts, 34, 1))
>K : Symbol(K, Decl(keyofAndIndexedAccess2.ts, 36, 12))
>a : Symbol(a, Decl(keyofAndIndexedAccess2.ts, 36, 30))
>key : Symbol(key, Decl(keyofAndIndexedAccess2.ts, 36, 36))
>K : Symbol(K, Decl(keyofAndIndexedAccess2.ts, 36, 12))
>b : Symbol(b, Decl(keyofAndIndexedAccess2.ts, 36, 62))
a = b;
>a : Symbol(a, Decl(keyofAndIndexedAccess2.ts, 36, 30))
>b : Symbol(b, Decl(keyofAndIndexedAccess2.ts, 36, 62))
b = a;
>b : Symbol(b, Decl(keyofAndIndexedAccess2.ts, 36, 62))
>a : Symbol(a, Decl(keyofAndIndexedAccess2.ts, 36, 30))
}
type Item = { a: string, b: number };
>Item : Symbol(Item, Decl(keyofAndIndexedAccess2.ts, 39, 1))
>a : Symbol(a, Decl(keyofAndIndexedAccess2.ts, 41, 13))
>b : Symbol(b, Decl(keyofAndIndexedAccess2.ts, 41, 24))
function f10<T extends Item, K extends keyof T>(obj: T, k1: string, k2: keyof Item, k3: keyof T, k4: K) {
>f10 : Symbol(f10, Decl(keyofAndIndexedAccess2.ts, 41, 37))
>T : Symbol(T, Decl(keyofAndIndexedAccess2.ts, 43, 13))
>Item : Symbol(Item, Decl(keyofAndIndexedAccess2.ts, 39, 1))
>K : Symbol(K, Decl(keyofAndIndexedAccess2.ts, 43, 28))
>T : Symbol(T, Decl(keyofAndIndexedAccess2.ts, 43, 13))
>obj : Symbol(obj, Decl(keyofAndIndexedAccess2.ts, 43, 48))
>T : Symbol(T, Decl(keyofAndIndexedAccess2.ts, 43, 13))
>k1 : Symbol(k1, Decl(keyofAndIndexedAccess2.ts, 43, 55))
>k2 : Symbol(k2, Decl(keyofAndIndexedAccess2.ts, 43, 67))
>Item : Symbol(Item, Decl(keyofAndIndexedAccess2.ts, 39, 1))
>k3 : Symbol(k3, Decl(keyofAndIndexedAccess2.ts, 43, 83))
>T : Symbol(T, Decl(keyofAndIndexedAccess2.ts, 43, 13))
>k4 : Symbol(k4, Decl(keyofAndIndexedAccess2.ts, 43, 96))
>K : Symbol(K, Decl(keyofAndIndexedAccess2.ts, 43, 28))
obj[k1] = 123; // Error
>obj : Symbol(obj, Decl(keyofAndIndexedAccess2.ts, 43, 48))
>k1 : Symbol(k1, Decl(keyofAndIndexedAccess2.ts, 43, 55))
obj[k2] = 123; // Error
>obj : Symbol(obj, Decl(keyofAndIndexedAccess2.ts, 43, 48))
>k2 : Symbol(k2, Decl(keyofAndIndexedAccess2.ts, 43, 67))
obj[k3] = 123; // Error
>obj : Symbol(obj, Decl(keyofAndIndexedAccess2.ts, 43, 48))
>k3 : Symbol(k3, Decl(keyofAndIndexedAccess2.ts, 43, 83))
obj[k4] = 123; // Error
>obj : Symbol(obj, Decl(keyofAndIndexedAccess2.ts, 43, 48))
>k4 : Symbol(k4, Decl(keyofAndIndexedAccess2.ts, 43, 96))
}
type Dict = Record<string, number>;
>Dict : Symbol(Dict, Decl(keyofAndIndexedAccess2.ts, 48, 1))
>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --))
function f11<K extends keyof Dict>(obj: Dict, k1: keyof Dict, k2: K) {
>f11 : Symbol(f11, Decl(keyofAndIndexedAccess2.ts, 50, 35))
>K : Symbol(K, Decl(keyofAndIndexedAccess2.ts, 52, 13))
>Dict : Symbol(Dict, Decl(keyofAndIndexedAccess2.ts, 48, 1))
>obj : Symbol(obj, Decl(keyofAndIndexedAccess2.ts, 52, 35))
>Dict : Symbol(Dict, Decl(keyofAndIndexedAccess2.ts, 48, 1))
>k1 : Symbol(k1, Decl(keyofAndIndexedAccess2.ts, 52, 45))
>Dict : Symbol(Dict, Decl(keyofAndIndexedAccess2.ts, 48, 1))
>k2 : Symbol(k2, Decl(keyofAndIndexedAccess2.ts, 52, 61))
>K : Symbol(K, Decl(keyofAndIndexedAccess2.ts, 52, 13))
obj.foo = 123;
>obj : Symbol(obj, Decl(keyofAndIndexedAccess2.ts, 52, 35))
obj[k1] = 123;
>obj : Symbol(obj, Decl(keyofAndIndexedAccess2.ts, 52, 35))
>k1 : Symbol(k1, Decl(keyofAndIndexedAccess2.ts, 52, 45))
obj[k2] = 123;
>obj : Symbol(obj, Decl(keyofAndIndexedAccess2.ts, 52, 35))
>k2 : Symbol(k2, Decl(keyofAndIndexedAccess2.ts, 52, 61))
}
function f12<T extends Readonly<Dict>, K extends keyof T>(obj: T, k1: keyof Dict, k2: keyof T, k3: K) {
>f12 : Symbol(f12, Decl(keyofAndIndexedAccess2.ts, 56, 1))
>T : Symbol(T, Decl(keyofAndIndexedAccess2.ts, 58, 13))
>Readonly : Symbol(Readonly, Decl(lib.es5.d.ts, --, --))
>Dict : Symbol(Dict, Decl(keyofAndIndexedAccess2.ts, 48, 1))
>K : Symbol(K, Decl(keyofAndIndexedAccess2.ts, 58, 38))
>T : Symbol(T, Decl(keyofAndIndexedAccess2.ts, 58, 13))
>obj : Symbol(obj, Decl(keyofAndIndexedAccess2.ts, 58, 58))
>T : Symbol(T, Decl(keyofAndIndexedAccess2.ts, 58, 13))
>k1 : Symbol(k1, Decl(keyofAndIndexedAccess2.ts, 58, 65))
>Dict : Symbol(Dict, Decl(keyofAndIndexedAccess2.ts, 48, 1))
>k2 : Symbol(k2, Decl(keyofAndIndexedAccess2.ts, 58, 81))
>T : Symbol(T, Decl(keyofAndIndexedAccess2.ts, 58, 13))
>k3 : Symbol(k3, Decl(keyofAndIndexedAccess2.ts, 58, 94))
>K : Symbol(K, Decl(keyofAndIndexedAccess2.ts, 58, 38))
obj.foo = 123; // Error
>obj : Symbol(obj, Decl(keyofAndIndexedAccess2.ts, 58, 58))
obj[k1] = 123; // Error
>obj : Symbol(obj, Decl(keyofAndIndexedAccess2.ts, 58, 58))
>k1 : Symbol(k1, Decl(keyofAndIndexedAccess2.ts, 58, 65))
obj[k2] = 123; // Error
>obj : Symbol(obj, Decl(keyofAndIndexedAccess2.ts, 58, 58))
>k2 : Symbol(k2, Decl(keyofAndIndexedAccess2.ts, 58, 81))
obj[k3] = 123; // Error
>obj : Symbol(obj, Decl(keyofAndIndexedAccess2.ts, 58, 58))
>k3 : Symbol(k3, Decl(keyofAndIndexedAccess2.ts, 58, 94))
}
// Repro from #27895
export interface Entity {
>Entity : Symbol(Entity, Decl(keyofAndIndexedAccess2.ts, 63, 1))
id: number | string;
>id : Symbol(Entity.id, Decl(keyofAndIndexedAccess2.ts, 67, 25))
}
export type IdOf<E extends Entity> = E['id'];
>IdOf : Symbol(IdOf, Decl(keyofAndIndexedAccess2.ts, 69, 1))
>E : Symbol(E, Decl(keyofAndIndexedAccess2.ts, 71, 17))
>Entity : Symbol(Entity, Decl(keyofAndIndexedAccess2.ts, 63, 1))
>E : Symbol(E, Decl(keyofAndIndexedAccess2.ts, 71, 17))
export interface EntityState<E extends Entity> {
>EntityState : Symbol(EntityState, Decl(keyofAndIndexedAccess2.ts, 71, 45))
>E : Symbol(E, Decl(keyofAndIndexedAccess2.ts, 73, 29))
>Entity : Symbol(Entity, Decl(keyofAndIndexedAccess2.ts, 63, 1))
ids: IdOf<E>[];
>ids : Symbol(EntityState.ids, Decl(keyofAndIndexedAccess2.ts, 73, 48))
>IdOf : Symbol(IdOf, Decl(keyofAndIndexedAccess2.ts, 69, 1))
>E : Symbol(E, Decl(keyofAndIndexedAccess2.ts, 73, 29))
entities: { [key: string]: E, [key: number]: E };
>entities : Symbol(EntityState.entities, Decl(keyofAndIndexedAccess2.ts, 74, 19))
>key : Symbol(key, Decl(keyofAndIndexedAccess2.ts, 75, 17))
>E : Symbol(E, Decl(keyofAndIndexedAccess2.ts, 73, 29))
>key : Symbol(key, Decl(keyofAndIndexedAccess2.ts, 75, 35))
>E : Symbol(E, Decl(keyofAndIndexedAccess2.ts, 73, 29))
}
export function getAllEntities<E extends Entity>(state: EntityState<E>): E[] {
>getAllEntities : Symbol(getAllEntities, Decl(keyofAndIndexedAccess2.ts, 76, 1))
>E : Symbol(E, Decl(keyofAndIndexedAccess2.ts, 79, 31))
>Entity : Symbol(Entity, Decl(keyofAndIndexedAccess2.ts, 63, 1))
>state : Symbol(state, Decl(keyofAndIndexedAccess2.ts, 79, 49))
>EntityState : Symbol(EntityState, Decl(keyofAndIndexedAccess2.ts, 71, 45))
>E : Symbol(E, Decl(keyofAndIndexedAccess2.ts, 79, 31))
>E : Symbol(E, Decl(keyofAndIndexedAccess2.ts, 79, 31))
const { ids, entities } = state;
>ids : Symbol(ids, Decl(keyofAndIndexedAccess2.ts, 80, 11))
>entities : Symbol(entities, Decl(keyofAndIndexedAccess2.ts, 80, 16))
>state : Symbol(state, Decl(keyofAndIndexedAccess2.ts, 79, 49))
return ids.map(id => entities[id]);
>ids.map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --))
>ids : Symbol(ids, Decl(keyofAndIndexedAccess2.ts, 80, 11))
>map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --))
>id : Symbol(id, Decl(keyofAndIndexedAccess2.ts, 81, 19))
>entities : Symbol(entities, Decl(keyofAndIndexedAccess2.ts, 80, 16))
>id : Symbol(id, Decl(keyofAndIndexedAccess2.ts, 81, 19))
}
export function getEntity<E extends Entity>(id: IdOf<E>, state: EntityState<E>): E | undefined {
>getEntity : Symbol(getEntity, Decl(keyofAndIndexedAccess2.ts, 82, 1))
>E : Symbol(E, Decl(keyofAndIndexedAccess2.ts, 84, 26))
>Entity : Symbol(Entity, Decl(keyofAndIndexedAccess2.ts, 63, 1))
>id : Symbol(id, Decl(keyofAndIndexedAccess2.ts, 84, 44))
>IdOf : Symbol(IdOf, Decl(keyofAndIndexedAccess2.ts, 69, 1))
>E : Symbol(E, Decl(keyofAndIndexedAccess2.ts, 84, 26))
>state : Symbol(state, Decl(keyofAndIndexedAccess2.ts, 84, 56))
>EntityState : Symbol(EntityState, Decl(keyofAndIndexedAccess2.ts, 71, 45))
>E : Symbol(E, Decl(keyofAndIndexedAccess2.ts, 84, 26))
>E : Symbol(E, Decl(keyofAndIndexedAccess2.ts, 84, 26))
const { ids, entities } = state;
>ids : Symbol(ids, Decl(keyofAndIndexedAccess2.ts, 85, 11))
>entities : Symbol(entities, Decl(keyofAndIndexedAccess2.ts, 85, 16))
>state : Symbol(state, Decl(keyofAndIndexedAccess2.ts, 84, 56))
if (!ids.includes(id)) {
>ids.includes : Symbol(Array.includes, Decl(lib.es2016.array.include.d.ts, --, --))
>ids : Symbol(ids, Decl(keyofAndIndexedAccess2.ts, 85, 11))
>includes : Symbol(Array.includes, Decl(lib.es2016.array.include.d.ts, --, --))
>id : Symbol(id, Decl(keyofAndIndexedAccess2.ts, 84, 44))
return undefined;
>undefined : Symbol(undefined)
}
return entities[id];
>entities : Symbol(entities, Decl(keyofAndIndexedAccess2.ts, 85, 16))
>id : Symbol(id, Decl(keyofAndIndexedAccess2.ts, 84, 44))
}
// Repro from #30603
interface Type {
>Type : Symbol(Type, Decl(keyofAndIndexedAccess2.ts, 92, 1))
a: 123;
>a : Symbol(Type.a, Decl(keyofAndIndexedAccess2.ts, 96, 16))
b: "some string";
>b : Symbol(Type.b, Decl(keyofAndIndexedAccess2.ts, 97, 11))
}
function get123<K extends keyof Type>(): Type[K] {
>get123 : Symbol(get123, Decl(keyofAndIndexedAccess2.ts, 99, 1))
>K : Symbol(K, Decl(keyofAndIndexedAccess2.ts, 101, 16))
>Type : Symbol(Type, Decl(keyofAndIndexedAccess2.ts, 92, 1))
>Type : Symbol(Type, Decl(keyofAndIndexedAccess2.ts, 92, 1))
>K : Symbol(K, Decl(keyofAndIndexedAccess2.ts, 101, 16))
return 123; // Error
}

View File

@@ -0,0 +1,408 @@
=== tests/cases/conformance/types/keyof/keyofAndIndexedAccess2.ts ===
function f1(obj: { a: number, b: 0 | 1, c: string }, k0: 'a', k1: 'a' | 'b', k2: 'a' | 'b' | 'c') {
>f1 : (obj: { a: number; b: 0 | 1; c: string; }, k0: "a", k1: "a" | "b", k2: "a" | "b" | "c") => void
>obj : { a: number; b: 0 | 1; c: string; }
>a : number
>b : 0 | 1
>c : string
>k0 : "a"
>k1 : "a" | "b"
>k2 : "a" | "b" | "c"
obj[k0] = 1;
>obj[k0] = 1 : 1
>obj[k0] : number
>obj : { a: number; b: 0 | 1; c: string; }
>k0 : "a"
>1 : 1
obj[k0] = 2;
>obj[k0] = 2 : 2
>obj[k0] : number
>obj : { a: number; b: 0 | 1; c: string; }
>k0 : "a"
>2 : 2
obj[k0] = 'x'; // Error
>obj[k0] = 'x' : "x"
>obj[k0] : number
>obj : { a: number; b: 0 | 1; c: string; }
>k0 : "a"
>'x' : "x"
obj[k1] = 1;
>obj[k1] = 1 : 1
>obj[k1] : 0 | 1
>obj : { a: number; b: 0 | 1; c: string; }
>k1 : "a" | "b"
>1 : 1
obj[k1] = 2; // Error
>obj[k1] = 2 : 2
>obj[k1] : 0 | 1
>obj : { a: number; b: 0 | 1; c: string; }
>k1 : "a" | "b"
>2 : 2
obj[k1] = 'x'; // Error
>obj[k1] = 'x' : "x"
>obj[k1] : 0 | 1
>obj : { a: number; b: 0 | 1; c: string; }
>k1 : "a" | "b"
>'x' : "x"
obj[k2] = 1; // Error
>obj[k2] = 1 : 1
>obj[k2] : never
>obj : { a: number; b: 0 | 1; c: string; }
>k2 : "a" | "b" | "c"
>1 : 1
obj[k2] = 2; // Error
>obj[k2] = 2 : 2
>obj[k2] : never
>obj : { a: number; b: 0 | 1; c: string; }
>k2 : "a" | "b" | "c"
>2 : 2
obj[k2] = 'x'; // Error
>obj[k2] = 'x' : "x"
>obj[k2] : never
>obj : { a: number; b: 0 | 1; c: string; }
>k2 : "a" | "b" | "c"
>'x' : "x"
}
function f2<T extends { [key: string]: number }>(a: { x: number, y: number }, b: { [key: string]: number }, c: T, k: keyof T) {
>f2 : <T extends { [key: string]: number; }>(a: { x: number; y: number; }, b: { [key: string]: number; }, c: T, k: keyof T) => void
>key : string
>a : { x: number; y: number; }
>x : number
>y : number
>b : { [key: string]: number; }
>key : string
>c : T
>k : keyof T
a = b; // Error, index signature in source doesn't imply properties are present
>a = b : { [key: string]: number; }
>a : { x: number; y: number; }
>b : { [key: string]: number; }
a = c; // Error, index signature in source doesn't imply properties are present
>a = c : T
>a : { x: number; y: number; }
>c : T
b = a;
>b = a : { x: number; y: number; }
>b : { [key: string]: number; }
>a : { x: number; y: number; }
b = c;
>b = c : T
>b : { [key: string]: number; }
>c : T
c = a; // Error, constraint on target doesn't imply any properties or signatures
>c = a : { x: number; y: number; }
>c : T
>a : { x: number; y: number; }
c = b; // Error, constraint on target doesn't imply any properties or signatures
>c = b : { [key: string]: number; }
>c : T
>b : { [key: string]: number; }
a.x;
>a.x : number
>a : { x: number; y: number; }
>x : number
b.x;
>b.x : number
>b : { [key: string]: number; }
>x : number
c.x;
>c.x : number
>c : T
>x : number
c[k];
>c[k] : T[keyof T]
>c : T
>k : keyof T
a.x = 1;
>a.x = 1 : 1
>a.x : number
>a : { x: number; y: number; }
>x : number
>1 : 1
b.x = 1;
>b.x = 1 : 1
>b.x : number
>b : { [key: string]: number; }
>x : number
>1 : 1
c.x = 1; // Error, cannot write to index signature through constraint
>c.x = 1 : 1
>c.x : any
>c : T
>x : any
>1 : 1
c[k] = 1; // Error, cannot write to index signature through constraint
>c[k] = 1 : 1
>c[k] : T[keyof T]
>c : T
>k : keyof T
>1 : 1
}
function f3<K extends string>(a: { [P in K]: number }, b: { [key: string]: number }, k: K) {
>f3 : <K extends string>(a: { [P in K]: number; }, b: { [key: string]: number; }, k: K) => void
>a : { [P in K]: number; }
>b : { [key: string]: number; }
>key : string
>k : K
a = b; // Error, index signature doesn't imply properties are present
>a = b : { [key: string]: number; }
>a : { [P in K]: number; }
>b : { [key: string]: number; }
b = a;
>b = a : { [P in K]: number; }
>b : { [key: string]: number; }
>a : { [P in K]: number; }
a[k];
>a[k] : { [P in K]: number; }[K]
>a : { [P in K]: number; }
>k : K
a[k] = 1;
>a[k] = 1 : 1
>a[k] : { [P in K]: number; }[K]
>a : { [P in K]: number; }
>k : K
>1 : 1
}
function f4<K extends string>(a: { [key: string]: number }[K], b: number) {
>f4 : <K extends string>(a: { [key: string]: number; }[K], b: number) => void
>a : { [key: string]: number; }[K]
>key : string
>b : number
a = b;
>a = b : number
>a : { [key: string]: number; }[K]
>b : number
b = a;
>b = a : { [key: string]: number; }[K]
>b : number
>a : { [key: string]: number; }[K]
}
type Item = { a: string, b: number };
>Item : Item
>a : string
>b : number
function f10<T extends Item, K extends keyof T>(obj: T, k1: string, k2: keyof Item, k3: keyof T, k4: K) {
>f10 : <T extends Item, K extends keyof T>(obj: T, k1: string, k2: "a" | "b", k3: keyof T, k4: K) => void
>obj : T
>k1 : string
>k2 : "a" | "b"
>k3 : keyof T
>k4 : K
obj[k1] = 123; // Error
>obj[k1] = 123 : 123
>obj[k1] : any
>obj : T
>k1 : string
>123 : 123
obj[k2] = 123; // Error
>obj[k2] = 123 : 123
>obj[k2] : string & number
>obj : T
>k2 : "a" | "b"
>123 : 123
obj[k3] = 123; // Error
>obj[k3] = 123 : 123
>obj[k3] : T[keyof T]
>obj : T
>k3 : keyof T
>123 : 123
obj[k4] = 123; // Error
>obj[k4] = 123 : 123
>obj[k4] : T[K]
>obj : T
>k4 : K
>123 : 123
}
type Dict = Record<string, number>;
>Dict : Record<string, number>
function f11<K extends keyof Dict>(obj: Dict, k1: keyof Dict, k2: K) {
>f11 : <K extends string>(obj: Record<string, number>, k1: string, k2: K) => void
>obj : Record<string, number>
>k1 : string
>k2 : K
obj.foo = 123;
>obj.foo = 123 : 123
>obj.foo : number
>obj : Record<string, number>
>foo : number
>123 : 123
obj[k1] = 123;
>obj[k1] = 123 : 123
>obj[k1] : number
>obj : Record<string, number>
>k1 : string
>123 : 123
obj[k2] = 123;
>obj[k2] = 123 : 123
>obj[k2] : Record<string, number>[K]
>obj : Record<string, number>
>k2 : K
>123 : 123
}
function f12<T extends Readonly<Dict>, K extends keyof T>(obj: T, k1: keyof Dict, k2: keyof T, k3: K) {
>f12 : <T extends Readonly<Record<string, number>>, K extends keyof T>(obj: T, k1: string, k2: keyof T, k3: K) => void
>obj : T
>k1 : string
>k2 : keyof T
>k3 : K
obj.foo = 123; // Error
>obj.foo = 123 : 123
>obj.foo : any
>obj : T
>foo : any
>123 : 123
obj[k1] = 123; // Error
>obj[k1] = 123 : 123
>obj[k1] : any
>obj : T
>k1 : string
>123 : 123
obj[k2] = 123; // Error
>obj[k2] = 123 : 123
>obj[k2] : T[keyof T]
>obj : T
>k2 : keyof T
>123 : 123
obj[k3] = 123; // Error
>obj[k3] = 123 : 123
>obj[k3] : T[K]
>obj : T
>k3 : K
>123 : 123
}
// Repro from #27895
export interface Entity {
id: number | string;
>id : string | number
}
export type IdOf<E extends Entity> = E['id'];
>IdOf : E["id"]
export interface EntityState<E extends Entity> {
ids: IdOf<E>[];
>ids : E["id"][]
entities: { [key: string]: E, [key: number]: E };
>entities : { [key: string]: E; [key: number]: E; }
>key : string
>key : number
}
export function getAllEntities<E extends Entity>(state: EntityState<E>): E[] {
>getAllEntities : <E extends Entity>(state: EntityState<E>) => E[]
>state : EntityState<E>
const { ids, entities } = state;
>ids : E["id"][]
>entities : { [key: string]: E; [key: number]: E; }
>state : EntityState<E>
return ids.map(id => entities[id]);
>ids.map(id => entities[id]) : { [key: string]: E; [key: number]: E; }[E["id"]][]
>ids.map : <U>(callbackfn: (value: E["id"], index: number, array: E["id"][]) => U, thisArg?: any) => U[]
>ids : E["id"][]
>map : <U>(callbackfn: (value: E["id"], index: number, array: E["id"][]) => U, thisArg?: any) => U[]
>id => entities[id] : (id: E["id"]) => { [key: string]: E; [key: number]: E; }[E["id"]]
>id : E["id"]
>entities[id] : { [key: string]: E; [key: number]: E; }[E["id"]]
>entities : { [key: string]: E; [key: number]: E; }
>id : E["id"]
}
export function getEntity<E extends Entity>(id: IdOf<E>, state: EntityState<E>): E | undefined {
>getEntity : <E extends Entity>(id: E["id"], state: EntityState<E>) => E | undefined
>id : E["id"]
>state : EntityState<E>
const { ids, entities } = state;
>ids : E["id"][]
>entities : { [key: string]: E; [key: number]: E; }
>state : EntityState<E>
if (!ids.includes(id)) {
>!ids.includes(id) : boolean
>ids.includes(id) : boolean
>ids.includes : (searchElement: E["id"], fromIndex?: number | undefined) => boolean
>ids : E["id"][]
>includes : (searchElement: E["id"], fromIndex?: number | undefined) => boolean
>id : E["id"]
return undefined;
>undefined : undefined
}
return entities[id];
>entities[id] : { [key: string]: E; [key: number]: E; }[E["id"]]
>entities : { [key: string]: E; [key: number]: E; }
>id : E["id"]
}
// Repro from #30603
interface Type {
a: 123;
>a : 123
b: "some string";
>b : "some string"
}
function get123<K extends keyof Type>(): Type[K] {
>get123 : <K extends "a" | "b">() => Type[K]
return 123; // Error
>123 : 123
}