You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
tests/cases/conformance/types/conditional/conditionalTypes1.ts(24,5): error TS2322: Type 'T[keyof T] | undefined' is not assignable to type 'NonNullable<Partial<T>[keyof T]>'.
12
12
Type 'undefined' is not assignable to type 'T[keyof T] & {}'.
13
13
Type 'undefined' is not assignable to type 'T[keyof T]'.
14
+
'T[keyof T]' could be instantiated with an arbitrary type which could be unrelated to 'undefined'.
14
15
tests/cases/conformance/types/conditional/conditionalTypes1.ts(29,5): error TS2322: Type 'T["x"]' is not assignable to type 'NonNullable<T["x"]>'.
15
16
Type 'string | undefined' is not assignable to type 'NonNullable<T["x"]>'.
16
17
Type 'undefined' is not assignable to type 'NonNullable<T["x"]>'.
'{ [key: string]: number; }' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{ [key: string]: number; }'.
14
14
tests/cases/conformance/types/keyof/keyofAndIndexedAccess2.ts(26,7): error TS2339: Property 'x' does not exist on type 'T'.
15
15
tests/cases/conformance/types/keyof/keyofAndIndexedAccess2.ts(27,5): error TS2322: Type 'number' is not assignable to type 'T[keyof T]'.
16
+
'number' is assignable to the constraint of type 'T[keyof T]', but 'T[keyof T]' could be instantiated with a different subtype of constraint 'number'.
16
17
tests/cases/conformance/types/keyof/keyofAndIndexedAccess2.ts(31,5): error TS2322: Type '{ [key: string]: number; }' is not assignable to type '{ [P in K]: number; }'.
17
18
tests/cases/conformance/types/keyof/keyofAndIndexedAccess2.ts(38,5): error TS2322: Type '{ [x: string]: number; }' is not assignable to type '{ [P in K]: number; }'.
18
19
tests/cases/conformance/types/keyof/keyofAndIndexedAccess2.ts(50,3): error TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type 'Item'.
19
20
No index signature with a parameter of type 'string' was found on type 'Item'.
20
21
tests/cases/conformance/types/keyof/keyofAndIndexedAccess2.ts(51,3): error TS2322: Type 'number' is not assignable to type 'never'.
21
22
tests/cases/conformance/types/keyof/keyofAndIndexedAccess2.ts(52,3): error TS2322: Type 'number' is not assignable to type 'T[keyof T]'.
23
+
'T[keyof T]' could be instantiated with an arbitrary type which could be unrelated to 'number'.
22
24
tests/cases/conformance/types/keyof/keyofAndIndexedAccess2.ts(53,3): error TS2322: Type 'number' is not assignable to type 'T[K]'.
25
+
'T[K]' could be instantiated with an arbitrary type which could be unrelated to 'number'.
23
26
tests/cases/conformance/types/keyof/keyofAndIndexedAccess2.ts(65,7): error TS2339: Property 'foo' does not exist on type 'T'.
24
27
tests/cases/conformance/types/keyof/keyofAndIndexedAccess2.ts(66,3): error TS2536: Type 'string' cannot be used to index type 'T'.
25
28
tests/cases/conformance/types/keyof/keyofAndIndexedAccess2.ts(67,3): error TS2322: Type 'number' is not assignable to type 'T[keyof T]'.
29
+
'number' is assignable to the constraint of type 'T[keyof T]', but 'T[keyof T]' could be instantiated with a different subtype of constraint 'number'.
26
30
tests/cases/conformance/types/keyof/keyofAndIndexedAccess2.ts(68,3): error TS2322: Type 'number' is not assignable to type 'T[K]'.
31
+
'number' is assignable to the constraint of type 'T[K]', but 'T[K]' could be instantiated with a different subtype of constraint 'number'.
27
32
tests/cases/conformance/types/keyof/keyofAndIndexedAccess2.ts(108,5): error TS2322: Type '123' is not assignable to type 'Type[K]'.
c[k] = 1; // Error, cannot write to index signature through constraint
84
89
~~~~
85
90
!!! error TS2322: Type 'number' is not assignable to type 'T[keyof T]'.
91
+
!!! error TS2322: 'number' is assignable to the constraint of type 'T[keyof T]', but 'T[keyof T]' could be instantiated with a different subtype of constraint 'number'.
86
92
}
87
93
88
94
function f3<K extends string>(a: { [P in K]: number }, b: { [key: string]: number }, k: K) {
!!! error TS2322: Type 'number' is not assignable to type 'T[keyof T]'.
153
+
!!! error TS2322: 'number' is assignable to the constraint of type 'T[keyof T]', but 'T[keyof T]' could be instantiated with a different subtype of constraint 'number'.
145
154
obj[k3] = 123; // Error
146
155
~~~~~~~
147
156
!!! error TS2322: Type 'number' is not assignable to type 'T[K]'.
157
+
!!! error TS2322: 'number' is assignable to the constraint of type 'T[K]', but 'T[K]' could be instantiated with a different subtype of constraint 'number'.
!!! error TS2322: Type 'number' is not assignable to type 'T[K]'.
320
+
!!! error TS2322: 'number' is assignable to the constraint of type 'T[K]', but 'T[K]' could be instantiated with a different subtype of constraint 'any'.
315
321
t[k] = "hello"; // Error
316
322
~~~~
317
323
!!! error TS2322: Type 'string' is not assignable to type 'T[K]'.
324
+
!!! error TS2322: 'string' is assignable to the constraint of type 'T[K]', but 'T[K]' could be instantiated with a different subtype of constraint 'any'.
318
325
t[k] = [10, 20]; // Error
319
326
~~~~
320
327
!!! error TS2322: Type 'number[]' is not assignable to type 'T[K]'.
328
+
!!! error TS2322: 'number[]' is assignable to the constraint of type 'T[K]', but 'T[K]' could be instantiated with a different subtype of constraint 'any'.
let x: Partial<Partial<Partial<Partial<Partial<Partial<Partial<Record<keyof T, string>>>>>>>>[K] = "hello";
331
339
}
340
+
341
+
// Repro from #51069
342
+
343
+
class Test<T extends Record<string, number>> {
344
+
testy: T;
345
+
346
+
constructor(t: T) {
347
+
this.testy = t;
348
+
}
349
+
350
+
public t(key: keyof T): number {
351
+
this.testy[key] += 1; // Error
352
+
~~~~~~~~~~~~~~~
353
+
!!! error TS2322: Type 'number' is not assignable to type 'T[keyof T]'.
354
+
!!! error TS2322: 'number' is assignable to the constraint of type 'T[keyof T]', but 'T[keyof T]' could be instantiated with a different subtype of constraint 'number'.
0 commit comments