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
varianceReferences.ts(3,32): error TS2637: Variance annotations are only supported in type aliases for object, function, constructor, and mapped types.
2
-
varianceReferences.ts(8,28): error TS2637: Variance annotations are only supported in type aliases for object, function, constructor, and mapped types.
3
-
varianceReferences.ts(14,32): error TS2637: Variance annotations are only supported in type aliases for object, function, constructor, and mapped types.
2
+
varianceReferences.ts(9,1): error TS2322: Type '1 | 2' is not assignable to type '1'.
3
+
Type '2' is not assignable to type '1'.
4
+
varianceReferences.ts(14,28): error TS2637: Variance annotations are only supported in type aliases for object, function, constructor, and mapped types.
5
+
varianceReferences.ts(19,1): error TS2322: Type '1 | 2' is not assignable to type '1'.
6
+
Type '2' is not assignable to type '1'.
7
+
varianceReferences.ts(26,32): error TS2637: Variance annotations are only supported in type aliases for object, function, constructor, and mapped types.
8
+
varianceReferences.ts(31,1): error TS2322: Type '1 | 2' is not assignable to type '1'.
9
+
Type '2' is not assignable to type '1'.
10
+
varianceReferences.ts(38,20): error TS2637: Variance annotations are only supported in type aliases for object, function, constructor, and mapped types.
11
+
varianceReferences.ts(43,1): error TS2322: Type 'VarianceShape<1 | 2>' is not assignable to type 'VarianceShape<1>'.
12
+
Type '1 | 2' is not assignable to type '1'.
13
+
Type '2' is not assignable to type '1'.
14
+
varianceReferences.ts(53,24): error TS2637: Variance annotations are only supported in type aliases for object, function, constructor, and mapped types.
15
+
varianceReferences.ts(58,1): error TS2322: Type 'VarianceDeepShape<1 | 2>' is not assignable to type 'VarianceDeepShape<1>'.
16
+
Type '1 | 2' is not assignable to type '1'.
17
+
Type '2' is not assignable to type '1'.
4
18
5
19
6
-
==== varianceReferences.ts (3 errors) ====
20
+
==== varianceReferences.ts (10 errors) ====
7
21
type NumericConstraint<Value extends number> = Value;
8
22
9
23
type VarianceConstrainedNumber<in out Value extends number> =
10
24
~~~~~~~~~~~~~~~~~~~~~~~~~~~
11
25
!!! error TS2637: Variance annotations are only supported in type aliases for object, function, constructor, and mapped types.
12
26
NumericConstraint<Value>;
13
27
28
+
declare let vcn1: VarianceConstrainedNumber<1>;
29
+
declare let vcn12: VarianceConstrainedNumber<1 | 2>;
30
+
31
+
vcn1 = vcn12;
32
+
~~~~
33
+
!!! error TS2322: Type '1 | 2' is not assignable to type '1'.
34
+
!!! error TS2322: Type '2' is not assignable to type '1'.
35
+
vcn12 = vcn1;
36
+
14
37
type Unconstrained<Value> = Value;
15
38
16
39
type VarianceUnconstrained<in out Value> = Unconstrained<Value>;
17
40
~~~~~~~~~~~~
18
41
!!! error TS2637: Variance annotations are only supported in type aliases for object, function, constructor, and mapped types.
19
42
43
+
declare let vu1: VarianceUnconstrained<1>;
44
+
declare let vu12: VarianceUnconstrained<1 | 2>;
45
+
46
+
vu1 = vu12;
47
+
~~~
48
+
!!! error TS2322: Type '1 | 2' is not assignable to type '1'.
49
+
!!! error TS2322: Type '2' is not assignable to type '1'.
50
+
vu12 = vu1;
51
+
20
52
type Level3of3Unconstrained<Value> = Value;
21
53
type Level2of3Unconstrained<Value> = Level3of3Unconstrained<Value>;
22
54
type Level1of3Unconstrained<Value> = Level2of3Unconstrained<Value>;
@@ -25,11 +57,32 @@ varianceReferences.ts(14,32): error TS2637: Variance annotations are only suppor
25
57
~~~~~~~~~~~~
26
58
!!! error TS2637: Variance annotations are only supported in type aliases for object, function, constructor, and mapped types.
27
59
60
+
declare let vdu1: VarianceDeepUnconstrained<1>;
61
+
declare let vdu12: VarianceDeepUnconstrained<1 | 2>;
62
+
63
+
vdu1 = vdu12;
64
+
~~~~
65
+
!!! error TS2322: Type '1 | 2' is not assignable to type '1'.
66
+
!!! error TS2322: Type '2' is not assignable to type '1'.
67
+
vdu12 = vdu1;
68
+
28
69
interface Shape<Value> {
29
70
value: Value;
30
71
}
31
72
32
73
type VarianceShape<in out Value> = Shape<Value>;
74
+
~~~~~~~~~~~~
75
+
!!! error TS2637: Variance annotations are only supported in type aliases for object, function, constructor, and mapped types.
76
+
77
+
declare let vs1: VarianceShape<1>;
78
+
declare let vs12: VarianceShape<1 | 2>;
79
+
80
+
vs1 = vs12;
81
+
~~~
82
+
!!! error TS2322: Type 'VarianceShape<1 | 2>' is not assignable to type 'VarianceShape<1>'.
83
+
!!! error TS2322: Type '1 | 2' is not assignable to type '1'.
84
+
!!! error TS2322: Type '2' is not assignable to type '1'.
85
+
vs12 = vs1;
33
86
34
87
interface Level3of3Shape<Value> {
35
88
value: Value;
@@ -39,4 +92,16 @@ varianceReferences.ts(14,32): error TS2637: Variance annotations are only suppor
39
92
type Level1of3Shape<Value> = Level2of3Shape<Value>;
40
93
41
94
type VarianceDeepShape<in out Value> = Level1of3Shape<Value>;
95
+
~~~~~~~~~~~~
96
+
!!! error TS2637: Variance annotations are only supported in type aliases for object, function, constructor, and mapped types.
97
+
98
+
declare let vds1: VarianceDeepShape<1>;
99
+
declare let vds12: VarianceDeepShape<1 | 2>;
100
+
101
+
vds1 = vds12;
102
+
~~~~
103
+
!!! error TS2322: Type 'VarianceDeepShape<1 | 2>' is not assignable to type 'VarianceDeepShape<1>'.
104
+
!!! error TS2322: Type '1 | 2' is not assignable to type '1'.
105
+
!!! error TS2322: Type '2' is not assignable to type '1'.
0 commit comments