Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit defd32f

Browse filesBrowse files
committed
Move strict tuple test and add a couple of cases
1 parent 5d7e87a commit defd32f
Copy full SHA for defd32f

7 files changed

+139-88Lines changed: 139 additions & 88 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file
+37Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
tests/cases/conformance/types/tuple/strictTupleLength.ts(1,9): error TS1122: A tuple type element list cannot be empty.
2+
tests/cases/conformance/types/tuple/strictTupleLength.ts(11,5): error TS2403: Subsequent variable declarations must have the same type. Variable 't1' has type '[number]' at tests/cases/conformance/types/tuple/strictTupleLength.ts 1:4, but here has type '[number, number]'.
3+
tests/cases/conformance/types/tuple/strictTupleLength.ts(12,5): error TS2403: Subsequent variable declarations must have the same type. Variable 't2' has type '[number, number]' at tests/cases/conformance/types/tuple/strictTupleLength.ts 2:4, but here has type '[number]'.
4+
tests/cases/conformance/types/tuple/strictTupleLength.ts(18,1): error TS2322: Type 'number[]' is not assignable to type '[number]'.
5+
Property '0' is missing in type 'number[]'.
6+
7+
8+
==== tests/cases/conformance/types/tuple/strictTupleLength.ts (4 errors) ====
9+
var t0: [];
10+
~~
11+
!!! error TS1122: A tuple type element list cannot be empty.
12+
var t1: [number];
13+
var t2: [number, number];
14+
var arr: number[];
15+
16+
var len0: 0 = t0.length;
17+
var len1: 1 = t1.length;
18+
var len2: 2 = t2.length;
19+
var lena: number = arr.length;
20+
21+
var t1 = t2; // error
22+
~~
23+
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 't1' has type '[number]' at tests/cases/conformance/types/tuple/strictTupleLength.ts 1:4, but here has type '[number, number]'.
24+
var t2 = t1; // error
25+
~~
26+
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 't2' has type '[number, number]' at tests/cases/conformance/types/tuple/strictTupleLength.ts 2:4, but here has type '[number]'.
27+
28+
type A<T extends any[]> = T['length'];
29+
var b: A<[boolean]>;
30+
var c: 1 = b;
31+
32+
t1 = arr; // error with or without strict
33+
~~
34+
!!! error TS2322: Type 'number[]' is not assignable to type '[number]'.
35+
!!! error TS2322: Property '0' is missing in type 'number[]'.
36+
arr = t1; // ok with or without strict
37+
Collapse file
+11-6Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
//// [tupleLength.ts]
2-
// var t0: [];
1+
//// [strictTupleLength.ts]
2+
var t0: [];
33
var t1: [number];
44
var t2: [number, number];
55
var arr: number[];
66

7-
// var len0: 0 = t0.length;
7+
var len0: 0 = t0.length;
88
var len1: 1 = t1.length;
99
var len2: 2 = t2.length;
1010
var lena: number = arr.length;
@@ -15,18 +15,23 @@ var t2 = t1; // error
1515
type A<T extends any[]> = T['length'];
1616
var b: A<[boolean]>;
1717
var c: 1 = b;
18+
19+
t1 = arr; // error with or without strict
20+
arr = t1; // ok with or without strict
1821

1922

20-
//// [tupleLength.js]
21-
// var t0: [];
23+
//// [strictTupleLength.js]
24+
var t0;
2225
var t1;
2326
var t2;
2427
var arr;
25-
// var len0: 0 = t0.length;
28+
var len0 = t0.length;
2629
var len1 = t1.length;
2730
var len2 = t2.length;
2831
var lena = arr.length;
2932
var t1 = t2; // error
3033
var t2 = t1; // error
3134
var b;
3235
var c = b;
36+
t1 = arr; // error with or without strict
37+
arr = t1; // ok with or without strict
Collapse file
+66Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
=== tests/cases/conformance/types/tuple/strictTupleLength.ts ===
2+
var t0: [];
3+
>t0 : Symbol(t0, Decl(strictTupleLength.ts, 0, 3))
4+
5+
var t1: [number];
6+
>t1 : Symbol(t1, Decl(strictTupleLength.ts, 1, 3), Decl(strictTupleLength.ts, 10, 3))
7+
8+
var t2: [number, number];
9+
>t2 : Symbol(t2, Decl(strictTupleLength.ts, 2, 3), Decl(strictTupleLength.ts, 11, 3))
10+
11+
var arr: number[];
12+
>arr : Symbol(arr, Decl(strictTupleLength.ts, 3, 3))
13+
14+
var len0: 0 = t0.length;
15+
>len0 : Symbol(len0, Decl(strictTupleLength.ts, 5, 3))
16+
>t0.length : Symbol(length)
17+
>t0 : Symbol(t0, Decl(strictTupleLength.ts, 0, 3))
18+
>length : Symbol(length)
19+
20+
var len1: 1 = t1.length;
21+
>len1 : Symbol(len1, Decl(strictTupleLength.ts, 6, 3))
22+
>t1.length : Symbol(length)
23+
>t1 : Symbol(t1, Decl(strictTupleLength.ts, 1, 3), Decl(strictTupleLength.ts, 10, 3))
24+
>length : Symbol(length)
25+
26+
var len2: 2 = t2.length;
27+
>len2 : Symbol(len2, Decl(strictTupleLength.ts, 7, 3))
28+
>t2.length : Symbol(length)
29+
>t2 : Symbol(t2, Decl(strictTupleLength.ts, 2, 3), Decl(strictTupleLength.ts, 11, 3))
30+
>length : Symbol(length)
31+
32+
var lena: number = arr.length;
33+
>lena : Symbol(lena, Decl(strictTupleLength.ts, 8, 3))
34+
>arr.length : Symbol(Array.length, Decl(lib.d.ts, --, --))
35+
>arr : Symbol(arr, Decl(strictTupleLength.ts, 3, 3))
36+
>length : Symbol(Array.length, Decl(lib.d.ts, --, --))
37+
38+
var t1 = t2; // error
39+
>t1 : Symbol(t1, Decl(strictTupleLength.ts, 1, 3), Decl(strictTupleLength.ts, 10, 3))
40+
>t2 : Symbol(t2, Decl(strictTupleLength.ts, 2, 3), Decl(strictTupleLength.ts, 11, 3))
41+
42+
var t2 = t1; // error
43+
>t2 : Symbol(t2, Decl(strictTupleLength.ts, 2, 3), Decl(strictTupleLength.ts, 11, 3))
44+
>t1 : Symbol(t1, Decl(strictTupleLength.ts, 1, 3), Decl(strictTupleLength.ts, 10, 3))
45+
46+
type A<T extends any[]> = T['length'];
47+
>A : Symbol(A, Decl(strictTupleLength.ts, 11, 12))
48+
>T : Symbol(T, Decl(strictTupleLength.ts, 13, 7))
49+
>T : Symbol(T, Decl(strictTupleLength.ts, 13, 7))
50+
51+
var b: A<[boolean]>;
52+
>b : Symbol(b, Decl(strictTupleLength.ts, 14, 3))
53+
>A : Symbol(A, Decl(strictTupleLength.ts, 11, 12))
54+
55+
var c: 1 = b;
56+
>c : Symbol(c, Decl(strictTupleLength.ts, 15, 3))
57+
>b : Symbol(b, Decl(strictTupleLength.ts, 14, 3))
58+
59+
t1 = arr; // error with or without strict
60+
>t1 : Symbol(t1, Decl(strictTupleLength.ts, 1, 3), Decl(strictTupleLength.ts, 10, 3))
61+
>arr : Symbol(arr, Decl(strictTupleLength.ts, 3, 3))
62+
63+
arr = t1; // ok with or without strict
64+
>arr : Symbol(arr, Decl(strictTupleLength.ts, 3, 3))
65+
>t1 : Symbol(t1, Decl(strictTupleLength.ts, 1, 3), Decl(strictTupleLength.ts, 10, 3))
66+
Collapse file

‎…ts/baselines/reference/tupleLength.types‎ ‎…elines/reference/strictTupleLength.types‎tests/baselines/reference/tupleLength.types renamed to tests/baselines/reference/strictTupleLength.types tests/baselines/reference/tupleLength.types renamed to tests/baselines/reference/strictTupleLength.types

Copy file name to clipboardExpand all lines: tests/baselines/reference/strictTupleLength.types
+20-3Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
=== tests/cases/compiler/tupleLength.ts ===
2-
// var t0: [];
1+
=== tests/cases/conformance/types/tuple/strictTupleLength.ts ===
2+
var t0: [];
3+
>t0 : []
4+
35
var t1: [number];
46
>t1 : [number]
57

@@ -9,7 +11,12 @@ var t2: [number, number];
911
var arr: number[];
1012
>arr : number[]
1113

12-
// var len0: 0 = t0.length;
14+
var len0: 0 = t0.length;
15+
>len0 : 0
16+
>t0.length : 0
17+
>t0 : []
18+
>length : 0
19+
1320
var len1: 1 = t1.length;
1421
>len1 : 1
1522
>t1.length : 1
@@ -49,3 +56,13 @@ var c: 1 = b;
4956
>c : 1
5057
>b : 1
5158

59+
t1 = arr; // error with or without strict
60+
>t1 = arr : number[]
61+
>t1 : [number]
62+
>arr : number[]
63+
64+
arr = t1; // ok with or without strict
65+
>arr = t1 : [number]
66+
>arr : number[]
67+
>t1 : [number]
68+
Collapse file

‎tests/baselines/reference/tupleLength.errors.txt‎

Copy file name to clipboardExpand all lines: tests/baselines/reference/tupleLength.errors.txt
-26Lines changed: 0 additions & 26 deletions
This file was deleted.
Collapse file

‎tests/baselines/reference/tupleLength.symbols‎

Copy file name to clipboardExpand all lines: tests/baselines/reference/tupleLength.symbols
-51Lines changed: 0 additions & 51 deletions
This file was deleted.
Collapse file

‎tests/cases/compiler/tupleLength.ts‎ ‎…ormance/types/tuple/strictTupleLength.ts‎tests/cases/compiler/tupleLength.ts renamed to tests/cases/conformance/types/tuple/strictTupleLength.ts tests/cases/compiler/tupleLength.ts renamed to tests/cases/conformance/types/tuple/strictTupleLength.ts

Copy file name to clipboardExpand all lines: tests/cases/conformance/types/tuple/strictTupleLength.ts
+5-2Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// @strictTuples: true
22

3-
// var t0: [];
3+
var t0: [];
44
var t1: [number];
55
var t2: [number, number];
66
var arr: number[];
77

8-
// var len0: 0 = t0.length;
8+
var len0: 0 = t0.length;
99
var len1: 1 = t1.length;
1010
var len2: 2 = t2.length;
1111
var lena: number = arr.length;
@@ -16,3 +16,6 @@ var t2 = t1; // error
1616
type A<T extends any[]> = T['length'];
1717
var b: A<[boolean]>;
1818
var c: 1 = b;
19+
20+
t1 = arr; // error with or without strict
21+
arr = t1; // ok with or without strict

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.