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
Copy file name to clipboardExpand all lines: tests/baselines/reference/mappedTypeConstraints2.errors.txt
+48-8Lines changed: 48 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,25 @@
1
1
tests/cases/conformance/types/mapped/mappedTypeConstraints2.ts(10,11): error TS2322: Type 'Mapped2<K>[`get${K}`]' is not assignable to type '{ a: K; }'.
2
-
Type 'Mapped2<K>[`get${string}`]' is not assignable to type '{ a: K; }'.
2
+
Type '{ a: `get${K}`; }' is not assignable to type '{ a: K; }'.
3
+
Types of property 'a' are incompatible.
4
+
Type '`get${K}`' is not assignable to type 'K'.
5
+
'`get${K}`' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint 'string'.
6
+
Type '`get${string}`' is not assignable to type 'K'.
7
+
'`get${string}`' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint 'string'.
3
8
tests/cases/conformance/types/mapped/mappedTypeConstraints2.ts(16,11): error TS2322: Type 'Mapped3<K>[Uppercase<K>]' is not assignable to type '{ a: K; }'.
4
-
Type 'Mapped3<K>[Uppercase<string>]' is not assignable to type '{ a: K; }'.
5
-
Type 'Mapped3<K>[string]' is not assignable to type '{ a: K; }'.
9
+
Type '{ a: Uppercase<K>; }' is not assignable to type '{ a: K; }'.
10
+
Types of property 'a' are incompatible.
11
+
Type 'Uppercase<K>' is not assignable to type 'K'.
12
+
'Uppercase<K>' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint 'string'.
13
+
Type 'Uppercase<string>' is not assignable to type 'K'.
14
+
'Uppercase<string>' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint 'string'.
15
+
Type 'string' is not assignable to type 'K'.
16
+
'string' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint 'string'.
6
17
tests/cases/conformance/types/mapped/mappedTypeConstraints2.ts(25,57): error TS2322: Type 'Foo<T>[`get${T}`]' is not assignable to type 'T'.
7
-
'T' could be instantiated with an arbitrary type which could be unrelated to 'Foo<T>[`get${T}`]'.
18
+
'Foo<T>[`get${T}`]' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'string'.
19
+
Type '`get${T}`' is not assignable to type 'T'.
20
+
'`get${T}`' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'string'.
21
+
Type '`get${string}`' is not assignable to type 'T'.
22
+
'`get${string}`' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'string'.
!!! error TS2322: Type 'Mapped2<K>[`get${K}`]' is not assignable to type '{ a: K; }'.
23
-
!!! error TS2322: Type 'Mapped2<K>[`get${string}`]' is not assignable to type '{ a: K; }'.
38
+
!!! error TS2322: Type '{ a: `get${K}`; }' is not assignable to type '{ a: K; }'.
39
+
!!! error TS2322: Types of property 'a' are incompatible.
40
+
!!! error TS2322: Type '`get${K}`' is not assignable to type 'K'.
41
+
!!! error TS2322: '`get${K}`' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint 'string'.
42
+
!!! error TS2322: Type '`get${string}`' is not assignable to type 'K'.
43
+
!!! error TS2322: '`get${string}`' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint 'string'.
24
44
}
25
45
26
46
type Mapped3<K extends string> = { [P in K as Uppercase<P>]: { a: P } };
!!! error TS2322: Type 'Mapped3<K>[Uppercase<K>]' is not assignable to type '{ a: K; }'.
32
-
!!! error TS2322: Type 'Mapped3<K>[Uppercase<string>]' is not assignable to type '{ a: K; }'.
33
-
!!! error TS2322: Type 'Mapped3<K>[string]' is not assignable to type '{ a: K; }'.
52
+
!!! error TS2322: Type '{ a: Uppercase<K>; }' is not assignable to type '{ a: K; }'.
53
+
!!! error TS2322: Types of property 'a' are incompatible.
54
+
!!! error TS2322: Type 'Uppercase<K>' is not assignable to type 'K'.
55
+
!!! error TS2322: 'Uppercase<K>' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint 'string'.
56
+
!!! error TS2322: Type 'Uppercase<string>' is not assignable to type 'K'.
57
+
!!! error TS2322: 'Uppercase<string>' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint 'string'.
58
+
!!! error TS2322: Type 'string' is not assignable to type 'K'.
59
+
!!! error TS2322: 'string' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint 'string'.
const get = <T extends string>(t: T, foo: Foo<T>): T => foo[`get${t}`]; // Type 'Foo<T>[`get${T}`]' is not assignable to type 'T'
43
69
~~~~~~~~~~~~~~
44
70
!!! error TS2322: Type 'Foo<T>[`get${T}`]' is not assignable to type 'T'.
45
-
!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'Foo<T>[`get${T}`]'.
71
+
!!! error TS2322: 'Foo<T>[`get${T}`]' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'string'.
72
+
!!! error TS2322: Type '`get${T}`' is not assignable to type 'T'.
73
+
!!! error TS2322: '`get${T}`' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'string'.
74
+
!!! error TS2322: Type '`get${string}`' is not assignable to type 'T'.
75
+
!!! error TS2322: '`get${string}`' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'string'.
0 commit comments