|
| 1 | +templateLiteralTypes5.ts(10,7): error TS2322: Type '<T0 extends "a" | "b">(x: `${T0}`) => TypeMap[T0]' is not assignable to type 'F2'. |
| 2 | + Type 'TypeMap[T2]' is not assignable to type 'TypeMap[`${T2}`]'. |
| 3 | + Type 'T2' is not assignable to type '`${T2}`'. |
| 4 | + Type '"a" | "b"' is not assignable to type '`${T2}`'. |
| 5 | + Type '"a"' is not assignable to type '`${T2}`'. |
| 6 | +templateLiteralTypes5.ts(13,11): error TS2322: Type 'T3' is not assignable to type '`${T3}`'. |
| 7 | + Type '"a" | "b"' is not assignable to type '`${T3}`'. |
| 8 | + Type '"a"' is not assignable to type '`${T3}`'. |
| 9 | +templateLiteralTypes5.ts(14,11): error TS2322: Type '`${T3}`' is not assignable to type 'T3'. |
| 10 | + '`${T3}`' is assignable to the constraint of type 'T3', but 'T3' could be instantiated with a different subtype of constraint '"a" | "b"'. |
| 11 | + Type '"a" | "b"' is not assignable to type 'T3'. |
| 12 | + '"a" | "b"' is assignable to the constraint of type 'T3', but 'T3' could be instantiated with a different subtype of constraint '"a" | "b"'. |
| 13 | + Type '"a"' is not assignable to type 'T3'. |
| 14 | + '"a"' is assignable to the constraint of type 'T3', but 'T3' could be instantiated with a different subtype of constraint '"a" | "b"'. |
| 15 | + |
| 16 | + |
| 17 | +==== templateLiteralTypes5.ts (3 errors) ==== |
| 18 | + // https://github.com/microsoft/TypeScript/issues/55364 |
| 19 | + interface TypeMap { |
| 20 | + a: "A"; |
| 21 | + b: "B"; |
| 22 | + } |
| 23 | + declare const f: <T0 extends "a" | "b">(x: `${T0}`) => TypeMap[T0]; |
| 24 | + type F1 = <T1 extends "a" | "b">(x: `${T1}`) => TypeMap[T1]; |
| 25 | + const f1: F1 = f; |
| 26 | + type F2 = <T2 extends 'a' | 'b'>(x: `${T2}`) => TypeMap[`${T2}`] |
| 27 | + const f2: F2 = f |
| 28 | + ~~ |
| 29 | +!!! error TS2322: Type '<T0 extends "a" | "b">(x: `${T0}`) => TypeMap[T0]' is not assignable to type 'F2'. |
| 30 | +!!! error TS2322: Type 'TypeMap[T2]' is not assignable to type 'TypeMap[`${T2}`]'. |
| 31 | +!!! error TS2322: Type 'T2' is not assignable to type '`${T2}`'. |
| 32 | +!!! error TS2322: Type '"a" | "b"' is not assignable to type '`${T2}`'. |
| 33 | +!!! error TS2322: Type '"a"' is not assignable to type '`${T2}`'. |
| 34 | + |
| 35 | + function f3<T3 extends "a" | "b">(x: T3) { |
| 36 | + const test1: `${T3}` = x |
| 37 | + ~~~~~ |
| 38 | +!!! error TS2322: Type 'T3' is not assignable to type '`${T3}`'. |
| 39 | +!!! error TS2322: Type '"a" | "b"' is not assignable to type '`${T3}`'. |
| 40 | +!!! error TS2322: Type '"a"' is not assignable to type '`${T3}`'. |
| 41 | + const test2: T3 = "" as `${T3}`; |
| 42 | + ~~~~~ |
| 43 | +!!! error TS2322: Type '`${T3}`' is not assignable to type 'T3'. |
| 44 | +!!! error TS2322: '`${T3}`' is assignable to the constraint of type 'T3', but 'T3' could be instantiated with a different subtype of constraint '"a" | "b"'. |
| 45 | +!!! error TS2322: Type '"a" | "b"' is not assignable to type 'T3'. |
| 46 | +!!! error TS2322: '"a" | "b"' is assignable to the constraint of type 'T3', but 'T3' could be instantiated with a different subtype of constraint '"a" | "b"'. |
| 47 | +!!! error TS2322: Type '"a"' is not assignable to type 'T3'. |
| 48 | +!!! error TS2322: '"a"' is assignable to the constraint of type 'T3', but 'T3' could be instantiated with a different subtype of constraint '"a" | "b"'. |
| 49 | + } |
| 50 | + |
0 commit comments