1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
|
tests/cases/conformance/types/nonPrimitive/nonPrimitiveConstraintOfIndexAccessType.ts(3,5): error TS2322: Type 'string' is not assignable to type 'T[P]'.
'T[P]' could be instantiated with an arbitrary type which could be unrelated to 'string'.
tests/cases/conformance/types/nonPrimitive/nonPrimitiveConstraintOfIndexAccessType.ts(6,5): error TS2322: Type 'string' is not assignable to type 'T[P]'.
'T[P]' could be instantiated with an arbitrary type which could be unrelated to 'string'.
tests/cases/conformance/types/nonPrimitive/nonPrimitiveConstraintOfIndexAccessType.ts(9,5): error TS2322: Type 'string' is not assignable to type 'T[P]'.
'T[P]' could be instantiated with an arbitrary type which could be unrelated to 'string'.
tests/cases/conformance/types/nonPrimitive/nonPrimitiveConstraintOfIndexAccessType.ts(12,5): error TS2322: Type 'string' is not assignable to type 'T[P]'.
'T[P]' could be instantiated with an arbitrary type which could be unrelated to 'string'.
tests/cases/conformance/types/nonPrimitive/nonPrimitiveConstraintOfIndexAccessType.ts(15,5): error TS2322: Type 'string' is not assignable to type 'T[P]'.
'T[P]' could be instantiated with an arbitrary type which could be unrelated to 'string'.
tests/cases/conformance/types/nonPrimitive/nonPrimitiveConstraintOfIndexAccessType.ts(18,5): error TS2322: Type 'string' is not assignable to type 'T[P]'.
'T[P]' could be instantiated with an arbitrary type which could be unrelated to 'string'.
tests/cases/conformance/types/nonPrimitive/nonPrimitiveConstraintOfIndexAccessType.ts(21,5): error TS2322: Type 'string' is not assignable to type 'T[P]'.
'T[P]' could be instantiated with an arbitrary type which could be unrelated to 'string'.
tests/cases/conformance/types/nonPrimitive/nonPrimitiveConstraintOfIndexAccessType.ts(24,5): error TS2322: Type 'string' is not assignable to type 'T[P]'.
'T[P]' could be instantiated with an arbitrary type which could be unrelated to 'string'.
tests/cases/conformance/types/nonPrimitive/nonPrimitiveConstraintOfIndexAccessType.ts(27,5): error TS2322: Type 'string' is not assignable to type 'T[P]'.
'T[P]' could be instantiated with an arbitrary type which could be unrelated to 'string'.
tests/cases/conformance/types/nonPrimitive/nonPrimitiveConstraintOfIndexAccessType.ts(30,5): error TS2322: Type 'string' is not assignable to type 'T[P]'.
'T[P]' could be instantiated with an arbitrary type which could be unrelated to 'string'.
==== tests/cases/conformance/types/nonPrimitive/nonPrimitiveConstraintOfIndexAccessType.ts (10 errors) ====
// test for #15371
function f<T extends object, P extends keyof T>(s: string, tp: T[P]): void {
tp = s;
~~
!!! error TS2322: Type 'string' is not assignable to type 'T[P]'.
!!! error TS2322: 'T[P]' could be instantiated with an arbitrary type which could be unrelated to 'string'.
}
function g<T extends null, P extends keyof T>(s: string, tp: T[P]): void {
tp = s;
~~
!!! error TS2322: Type 'string' is not assignable to type 'T[P]'.
!!! error TS2322: 'T[P]' could be instantiated with an arbitrary type which could be unrelated to 'string'.
}
function h<T extends undefined, P extends keyof T>(s: string, tp: T[P]): void {
tp = s;
~~
!!! error TS2322: Type 'string' is not assignable to type 'T[P]'.
!!! error TS2322: 'T[P]' could be instantiated with an arbitrary type which could be unrelated to 'string'.
}
function i<T extends void, P extends keyof T>(s: string, tp: T[P]): void {
tp = s;
~~
!!! error TS2322: Type 'string' is not assignable to type 'T[P]'.
!!! error TS2322: 'T[P]' could be instantiated with an arbitrary type which could be unrelated to 'string'.
}
function j<T extends never, P extends keyof T>(s: string, tp: T[P]): void {
tp = s;
~~
!!! error TS2322: Type 'string' is not assignable to type 'T[P]'.
!!! error TS2322: 'T[P]' could be instantiated with an arbitrary type which could be unrelated to 'string'.
}
function k<T extends number, P extends keyof T>(s: string, tp: T[P]): void {
tp = s;
~~
!!! error TS2322: Type 'string' is not assignable to type 'T[P]'.
!!! error TS2322: 'T[P]' could be instantiated with an arbitrary type which could be unrelated to 'string'.
}
function o<T extends string, P extends keyof T>(s: string, tp: T[P]): void {
tp = s;
~~
!!! error TS2322: Type 'string' is not assignable to type 'T[P]'.
!!! error TS2322: 'T[P]' could be instantiated with an arbitrary type which could be unrelated to 'string'.
}
function l<T extends {}, P extends keyof T>(s: string, tp: T[P]): void {
tp = s;
~~
!!! error TS2322: Type 'string' is not assignable to type 'T[P]'.
!!! error TS2322: 'T[P]' could be instantiated with an arbitrary type which could be unrelated to 'string'.
}
function m<T extends { a: number }, P extends keyof T>(s: string, tp: T[P]): void {
tp = s;
~~
!!! error TS2322: Type 'string' is not assignable to type 'T[P]'.
!!! error TS2322: 'T[P]' could be instantiated with an arbitrary type which could be unrelated to 'string'.
}
function n<T extends { [s: string]: number }, P extends keyof T>(s: string, tp: T[P]): void {
tp = s;
~~
!!! error TS2322: Type 'string' is not assignable to type 'T[P]'.
!!! error TS2322: 'T[P]' could be instantiated with an arbitrary type which could be unrelated to 'string'.
}
|