1
- tests/cases/compiler/tupleTypes.ts(1,9): error TS1122: A tuple type element list cannot be empty.
2
- tests/cases/compiler/tupleTypes.ts(14,1): error TS2322: Type 'undefined[]' is not assignable to type '[number, string]'.
3
- Property '0' is missing in type 'undefined[]'.
1
+ tests/cases/compiler/tupleTypes.ts(14,1): error TS2322: Type '[]' is not assignable to type '[number, string]'.
2
+ Property '0' is missing in type '[]'.
4
3
tests/cases/compiler/tupleTypes.ts(15,1): error TS2322: Type '[number]' is not assignable to type '[number, string]'.
5
4
Property '1' is missing in type '[number]'.
6
5
tests/cases/compiler/tupleTypes.ts(17,1): error TS2322: Type '[string, number]' is not assignable to type '[number, string]'.
7
6
Type 'string' is not assignable to type 'number'.
8
- tests/cases/compiler/tupleTypes.ts(41,1): error TS2322: Type 'undefined[]' is not assignable to type '[number, string]'.
9
- tests/cases/compiler/tupleTypes.ts(47,1): error TS2322: Type '[number, string]' is not assignable to type 'number[]'.
7
+ tests/cases/compiler/tupleTypes.ts(25,1): error TS2322: Type '[number]' is not assignable to type '[]'.
8
+ Types of property 'pop' are incompatible.
9
+ Type '() => number' is not assignable to type '() => never'.
10
+ Type 'number' is not assignable to type 'never'.
11
+ tests/cases/compiler/tupleTypes.ts(48,1): error TS2322: Type '[]' is not assignable to type '[number, string]'.
12
+ tests/cases/compiler/tupleTypes.ts(55,1): error TS2322: Type '[number, string]' is not assignable to type 'number[]'.
10
13
Types of property 'pop' are incompatible.
11
14
Type '() => string | number' is not assignable to type '() => number'.
12
15
Type 'string | number' is not assignable to type 'number'.
13
16
Type 'string' is not assignable to type 'number'.
14
- tests/cases/compiler/tupleTypes.ts(49 ,1): error TS2322: Type '[number, {}]' is not assignable to type 'number[]'.
17
+ tests/cases/compiler/tupleTypes.ts(57 ,1): error TS2322: Type '[number, {}]' is not assignable to type 'number[]'.
15
18
Types of property 'pop' are incompatible.
16
19
Type '() => number | {}' is not assignable to type '() => number'.
17
20
Type 'number | {}' is not assignable to type 'number'.
18
21
Type '{}' is not assignable to type 'number'.
19
- tests/cases/compiler/tupleTypes.ts(50 ,1): error TS2322: Type '[number, number]' is not assignable to type '[number, string]'.
22
+ tests/cases/compiler/tupleTypes.ts(59 ,1): error TS2322: Type '[number, number]' is not assignable to type '[number, string]'.
20
23
Type 'number' is not assignable to type 'string'.
21
- tests/cases/compiler/tupleTypes.ts(51 ,1): error TS2322: Type '[number, {}]' is not assignable to type '[number, string]'.
24
+ tests/cases/compiler/tupleTypes.ts(60 ,1): error TS2322: Type '[number, {}]' is not assignable to type '[number, string]'.
22
25
Type '{}' is not assignable to type 'string'.
26
+ tests/cases/compiler/tupleTypes.ts(61,1): error TS2322: Type '[]' is not assignable to type '[number, string]'.
27
+ tests/cases/compiler/tupleTypes.ts(64,1): error TS2322: Type '[]' is not assignable to type '[number, {}]'.
28
+ Property '0' is missing in type '[]'.
29
+ tests/cases/compiler/tupleTypes.ts(65,1): error TS2322: Type '[number, string]' is not assignable to type '[]'.
30
+ Types of property 'pop' are incompatible.
31
+ Type '() => string | number' is not assignable to type '() => never'.
32
+ Type 'string | number' is not assignable to type 'never'.
33
+ Type 'string' is not assignable to type 'never'.
23
34
24
35
25
- ==== tests/cases/compiler/tupleTypes.ts (9 errors) ====
26
- var v1: []; // Error
27
- ~~
28
- !!! error TS1122: A tuple type element list cannot be empty.
36
+ ==== tests/cases/compiler/tupleTypes.ts (12 errors) ====
37
+ var v1: [];
29
38
var v2: [number];
30
39
var v3: [number, string];
31
40
var v4: [number, [string, string]];
@@ -40,8 +49,8 @@ tests/cases/compiler/tupleTypes.ts(51,1): error TS2322: Type '[number, {}]' is n
40
49
41
50
t = []; // Error
42
51
~
43
- !!! error TS2322: Type 'undefined []' is not assignable to type '[number, string]'.
44
- !!! error TS2322: Property '0' is missing in type 'undefined []'.
52
+ !!! error TS2322: Type '[]' is not assignable to type '[number, string]'.
53
+ !!! error TS2322: Property '0' is missing in type '[]'.
45
54
t = [1]; // Error
46
55
~
47
56
!!! error TS2322: Type '[number]' is not assignable to type '[number, string]'.
@@ -53,6 +62,18 @@ tests/cases/compiler/tupleTypes.ts(51,1): error TS2322: Type '[number, {}]' is n
53
62
!!! error TS2322: Type 'string' is not assignable to type 'number'.
54
63
t = [1, "hello", 2]; // Ok
55
64
65
+ var et: [];
66
+ var et0 = et[0]; // never
67
+ var et0: never;
68
+
69
+ et = []; // Ok
70
+ et = [1]; // Error
71
+ ~~
72
+ !!! error TS2322: Type '[number]' is not assignable to type '[]'.
73
+ !!! error TS2322: Types of property 'pop' are incompatible.
74
+ !!! error TS2322: Type '() => number' is not assignable to type '() => never'.
75
+ !!! error TS2322: Type 'number' is not assignable to type 'never'.
76
+
56
77
var tf: [string, (x: string) => number] = ["hello", x => x.length];
57
78
58
79
declare function ff<T, U>(a: T, b: [T, (x: T) => U]): U;
@@ -76,12 +97,13 @@ tests/cases/compiler/tupleTypes.ts(51,1): error TS2322: Type '[number, {}]' is n
76
97
tt = [undefined, undefined];
77
98
tt = []; // Error
78
99
~~
79
- !!! error TS2322: Type 'undefined []' is not assignable to type '[number, string]'.
100
+ !!! error TS2322: Type '[]' is not assignable to type '[number, string]'.
80
101
81
102
var a: number[];
82
103
var a1: [number, string];
83
104
var a2: [number, number];
84
105
var a3: [number, {}];
106
+ var a4: [];
85
107
a = a1; // Error
86
108
~
87
109
!!! error TS2322: Type '[number, string]' is not assignable to type 'number[]'.
@@ -97,6 +119,7 @@ tests/cases/compiler/tupleTypes.ts(51,1): error TS2322: Type '[number, {}]' is n
97
119
!!! error TS2322: Type '() => number | {}' is not assignable to type '() => number'.
98
120
!!! error TS2322: Type 'number | {}' is not assignable to type 'number'.
99
121
!!! error TS2322: Type '{}' is not assignable to type 'number'.
122
+ a = a4;
100
123
a1 = a2; // Error
101
124
~~
102
125
!!! error TS2322: Type '[number, number]' is not assignable to type '[number, string]'.
@@ -105,6 +128,20 @@ tests/cases/compiler/tupleTypes.ts(51,1): error TS2322: Type '[number, {}]' is n
105
128
~~
106
129
!!! error TS2322: Type '[number, {}]' is not assignable to type '[number, string]'.
107
130
!!! error TS2322: Type '{}' is not assignable to type 'string'.
131
+ a1 = a4; // Error
132
+ ~~
133
+ !!! error TS2322: Type '[]' is not assignable to type '[number, string]'.
108
134
a3 = a1;
109
135
a3 = a2;
136
+ a3 = a4; // Error
137
+ ~~
138
+ !!! error TS2322: Type '[]' is not assignable to type '[number, {}]'.
139
+ !!! error TS2322: Property '0' is missing in type '[]'.
140
+ a4 = a1; // Error
141
+ ~~
142
+ !!! error TS2322: Type '[number, string]' is not assignable to type '[]'.
143
+ !!! error TS2322: Types of property 'pop' are incompatible.
144
+ !!! error TS2322: Type '() => string | number' is not assignable to type '() => never'.
145
+ !!! error TS2322: Type 'string | number' is not assignable to type 'never'.
146
+ !!! error TS2322: Type 'string' is not assignable to type 'never'.
110
147
0 commit comments