|
| 1 | +tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(12,5): error TS2322: Type 'T[keyof T]' is not assignable to type 'U[keyof T]'. |
| 2 | + Type 'T' is not assignable to type 'U'. |
| 3 | +tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(17,5): error TS2322: Type 'T[K]' is not assignable to type 'U[K]'. |
| 4 | + Type 'T' is not assignable to type 'U'. |
| 5 | +tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(21,5): error TS2536: Type 'keyof U' cannot be used to index type 'T'. |
| 6 | +tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(22,12): error TS2536: Type 'keyof U' cannot be used to index type 'T'. |
| 7 | +tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(26,5): error TS2536: Type 'K' cannot be used to index type 'T'. |
| 8 | +tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(27,12): error TS2536: Type 'K' cannot be used to index type 'T'. |
| 9 | +tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(31,5): error TS2322: Type 'T[keyof T] | undefined' is not assignable to type 'T[keyof T]'. |
| 10 | + Type 'undefined' is not assignable to type 'T[keyof T]'. |
| 11 | +tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(36,5): error TS2322: Type 'T[K] | undefined' is not assignable to type 'T[K]'. |
| 12 | + Type 'undefined' is not assignable to type 'T[K]'. |
| 13 | +tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(41,5): error TS2322: Type 'U[keyof T] | undefined' is not assignable to type 'T[keyof T]'. |
| 14 | + Type 'undefined' is not assignable to type 'T[keyof T]'. |
| 15 | +tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(42,5): error TS2322: Type 'T[keyof T]' is not assignable to type 'U[keyof T] | undefined'. |
| 16 | + Type 'T[keyof T]' is not assignable to type 'U[keyof T]'. |
| 17 | + Type 'T' is not assignable to type 'U'. |
| 18 | +tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(46,5): error TS2322: Type 'U[K] | undefined' is not assignable to type 'T[K]'. |
| 19 | + Type 'undefined' is not assignable to type 'T[K]'. |
| 20 | +tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(47,5): error TS2322: Type 'T[K]' is not assignable to type 'U[K] | undefined'. |
| 21 | + Type 'T[K]' is not assignable to type 'U[K]'. |
| 22 | + Type 'T' is not assignable to type 'U'. |
| 23 | +tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(52,5): error TS2542: Index signature in type 'Readonly<T>' only permits reading. |
| 24 | +tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(57,5): error TS2542: Index signature in type 'Readonly<T>' only permits reading. |
| 25 | +tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(62,5): error TS2542: Index signature in type 'Readonly<U>' only permits reading. |
| 26 | +tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(67,5): error TS2542: Index signature in type 'Readonly<U>' only permits reading. |
| 27 | +tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(71,5): error TS2322: Type 'Partial<T>' is not assignable to type 'T'. |
| 28 | +tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(76,5): error TS2322: Type 'Partial<T>' is not assignable to type 'T'. |
| 29 | + |
| 30 | + |
| 31 | +==== tests/cases/conformance/types/mapped/mappedTypeRelationships.ts (18 errors) ==== |
| 32 | + |
| 33 | + function f1<T>(x: T, k: keyof T) { |
| 34 | + return x[k]; |
| 35 | + } |
| 36 | + |
| 37 | + function f2<T, K extends keyof T>(x: T, k: K) { |
| 38 | + return x[k]; |
| 39 | + } |
| 40 | + |
| 41 | + function f3<T, U extends T>(x: T, y: U, k: keyof T) { |
| 42 | + x[k] = y[k]; |
| 43 | + y[k] = x[k]; // Error |
| 44 | + ~~~~ |
| 45 | +!!! error TS2322: Type 'T[keyof T]' is not assignable to type 'U[keyof T]'. |
| 46 | +!!! error TS2322: Type 'T' is not assignable to type 'U'. |
| 47 | + } |
| 48 | + |
| 49 | + function f4<T, U extends T, K extends keyof T>(x: T, y: U, k: K) { |
| 50 | + x[k] = y[k]; |
| 51 | + y[k] = x[k]; // Error |
| 52 | + ~~~~ |
| 53 | +!!! error TS2322: Type 'T[K]' is not assignable to type 'U[K]'. |
| 54 | +!!! error TS2322: Type 'T' is not assignable to type 'U'. |
| 55 | + } |
| 56 | + |
| 57 | + function f5<T, U extends T>(x: T, y: U, k: keyof U) { |
| 58 | + x[k] = y[k]; // Error |
| 59 | + ~~~~ |
| 60 | +!!! error TS2536: Type 'keyof U' cannot be used to index type 'T'. |
| 61 | + y[k] = x[k]; // Error |
| 62 | + ~~~~ |
| 63 | +!!! error TS2536: Type 'keyof U' cannot be used to index type 'T'. |
| 64 | + } |
| 65 | + |
| 66 | + function f6<T, U extends T, K extends keyof U>(x: T, y: U, k: K) { |
| 67 | + x[k] = y[k]; // Error |
| 68 | + ~~~~ |
| 69 | +!!! error TS2536: Type 'K' cannot be used to index type 'T'. |
| 70 | + y[k] = x[k]; // Error |
| 71 | + ~~~~ |
| 72 | +!!! error TS2536: Type 'K' cannot be used to index type 'T'. |
| 73 | + } |
| 74 | + |
| 75 | + function f10<T>(x: T, y: Partial<T>, k: keyof T) { |
| 76 | + x[k] = y[k]; // Error |
| 77 | + ~~~~ |
| 78 | +!!! error TS2322: Type 'T[keyof T] | undefined' is not assignable to type 'T[keyof T]'. |
| 79 | +!!! error TS2322: Type 'undefined' is not assignable to type 'T[keyof T]'. |
| 80 | + y[k] = x[k]; |
| 81 | + } |
| 82 | + |
| 83 | + function f11<T, K extends keyof T>(x: T, y: Partial<T>, k: K) { |
| 84 | + x[k] = y[k]; // Error |
| 85 | + ~~~~ |
| 86 | +!!! error TS2322: Type 'T[K] | undefined' is not assignable to type 'T[K]'. |
| 87 | +!!! error TS2322: Type 'undefined' is not assignable to type 'T[K]'. |
| 88 | + y[k] = x[k]; |
| 89 | + } |
| 90 | + |
| 91 | + function f12<T, U extends T>(x: T, y: Partial<U>, k: keyof T) { |
| 92 | + x[k] = y[k]; // Error |
| 93 | + ~~~~ |
| 94 | +!!! error TS2322: Type 'U[keyof T] | undefined' is not assignable to type 'T[keyof T]'. |
| 95 | +!!! error TS2322: Type 'undefined' is not assignable to type 'T[keyof T]'. |
| 96 | + y[k] = x[k]; // Error |
| 97 | + ~~~~ |
| 98 | +!!! error TS2322: Type 'T[keyof T]' is not assignable to type 'U[keyof T] | undefined'. |
| 99 | +!!! error TS2322: Type 'T[keyof T]' is not assignable to type 'U[keyof T]'. |
| 100 | +!!! error TS2322: Type 'T' is not assignable to type 'U'. |
| 101 | + } |
| 102 | + |
| 103 | + function f13<T, U extends T, K extends keyof T>(x: T, y: Partial<U>, k: K) { |
| 104 | + x[k] = y[k]; // Error |
| 105 | + ~~~~ |
| 106 | +!!! error TS2322: Type 'U[K] | undefined' is not assignable to type 'T[K]'. |
| 107 | +!!! error TS2322: Type 'undefined' is not assignable to type 'T[K]'. |
| 108 | + y[k] = x[k]; // Error |
| 109 | + ~~~~ |
| 110 | +!!! error TS2322: Type 'T[K]' is not assignable to type 'U[K] | undefined'. |
| 111 | +!!! error TS2322: Type 'T[K]' is not assignable to type 'U[K]'. |
| 112 | +!!! error TS2322: Type 'T' is not assignable to type 'U'. |
| 113 | + } |
| 114 | + |
| 115 | + function f20<T>(x: T, y: Readonly<T>, k: keyof T) { |
| 116 | + x[k] = y[k]; |
| 117 | + y[k] = x[k]; // Error |
| 118 | + ~~~~ |
| 119 | +!!! error TS2542: Index signature in type 'Readonly<T>' only permits reading. |
| 120 | + } |
| 121 | + |
| 122 | + function f21<T, K extends keyof T>(x: T, y: Readonly<T>, k: K) { |
| 123 | + x[k] = y[k]; |
| 124 | + y[k] = x[k]; // Error |
| 125 | + ~~~~ |
| 126 | +!!! error TS2542: Index signature in type 'Readonly<T>' only permits reading. |
| 127 | + } |
| 128 | + |
| 129 | + function f22<T, U extends T>(x: T, y: Readonly<U>, k: keyof T) { |
| 130 | + x[k] = y[k]; |
| 131 | + y[k] = x[k]; // Error |
| 132 | + ~~~~ |
| 133 | +!!! error TS2542: Index signature in type 'Readonly<U>' only permits reading. |
| 134 | + } |
| 135 | + |
| 136 | + function f23<T, U extends T, K extends keyof T>(x: T, y: Readonly<U>, k: K) { |
| 137 | + x[k] = y[k]; |
| 138 | + y[k] = x[k]; // Error |
| 139 | + ~~~~ |
| 140 | +!!! error TS2542: Index signature in type 'Readonly<U>' only permits reading. |
| 141 | + } |
| 142 | + |
| 143 | + function f30<T>(x: T, y: Partial<T>) { |
| 144 | + x = y; // Error |
| 145 | + ~ |
| 146 | +!!! error TS2322: Type 'Partial<T>' is not assignable to type 'T'. |
| 147 | + y = x; |
| 148 | + } |
| 149 | + |
| 150 | + function f31<T>(x: T, y: Partial<T>) { |
| 151 | + x = y; // Error |
| 152 | + ~ |
| 153 | +!!! error TS2322: Type 'Partial<T>' is not assignable to type 'T'. |
| 154 | + y = x; |
| 155 | + } |
| 156 | + |
| 157 | + function f40<T>(x: T, y: Readonly<T>) { |
| 158 | + x = y; |
| 159 | + y = x; |
| 160 | + } |
| 161 | + |
| 162 | + function f41<T>(x: T, y: Readonly<T>) { |
| 163 | + x = y; |
| 164 | + y = x; |
| 165 | + } |
0 commit comments