Skip to content

Commit 3894d05

Browse files
committed
merge tests
1 parent 421a5f2 commit 3894d05

19 files changed

+82
-93
lines changed
Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,22 @@
11
tests/cases/compiler/restParameterWithBindingPattern3.ts(1,16): error TS2322: Type '1' is not assignable to type 'string'.
22
tests/cases/compiler/restParameterWithBindingPattern3.ts(1,23): error TS2322: Type 'true' is not assignable to type 'string'.
3+
tests/cases/compiler/restParameterWithBindingPattern3.ts(3,23): error TS1186: A rest element cannot have an initializer.
4+
tests/cases/compiler/restParameterWithBindingPattern3.ts(7,23): error TS2493: Tuple type '[boolean, string, number]' with length '3' cannot be assigned to tuple with length '4'.
35

46

5-
==== tests/cases/compiler/restParameterWithBindingPattern3.ts (2 errors) ====
7+
==== tests/cases/compiler/restParameterWithBindingPattern3.ts (4 errors) ====
68
function a(...[a = 1, b = true]: string[]) { }
79
~
810
!!! error TS2322: Type '1' is not assignable to type 'string'.
911
~
10-
!!! error TS2322: Type 'true' is not assignable to type 'string'.
12+
!!! error TS2322: Type 'true' is not assignable to type 'string'.
13+
14+
function b(...[...foo = []]: string[]) { }
15+
~
16+
!!! error TS1186: A rest element cannot have an initializer.
17+
18+
function c(...{0: a, length, 3: d}: [boolean, string, number]) { }
19+
20+
function d(...[a, , , d]: [boolean, string, number]) { }
21+
~
22+
!!! error TS2493: Tuple type '[boolean, string, number]' with length '3' cannot be assigned to tuple with length '4'.

tests/baselines/reference/restParameterWithBindingPattern3.js

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
//// [restParameterWithBindingPattern3.ts]
2-
function a(...[a = 1, b = true]: string[]) { }
2+
function a(...[a = 1, b = true]: string[]) { }
3+
4+
function b(...[...foo = []]: string[]) { }
5+
6+
function c(...{0: a, length, 3: d}: [boolean, string, number]) { }
7+
8+
function d(...[a, , , d]: [boolean, string, number]) { }
39

410
//// [restParameterWithBindingPattern3.js]
511
function a() {
@@ -9,3 +15,24 @@ function a() {
915
}
1016
var _b = _a[0], a = _b === void 0 ? 1 : _b, _c = _a[1], b = _c === void 0 ? true : _c;
1117
}
18+
function b() {
19+
var _a = [];
20+
for (var _i = 0; _i < arguments.length; _i++) {
21+
_a[_i] = arguments[_i];
22+
}
23+
var _b = _a.slice(0), foo = _b === void 0 ? [] : _b;
24+
}
25+
function c() {
26+
var _a = [];
27+
for (var _i = 0; _i < arguments.length; _i++) {
28+
_a[_i] = arguments[_i];
29+
}
30+
var a = _a[0], length = _a.length, d = _a[3];
31+
}
32+
function d() {
33+
var _a = [];
34+
for (var _i = 0; _i < arguments.length; _i++) {
35+
_a[_i] = arguments[_i];
36+
}
37+
var a = _a[0], d = _a[3];
38+
}

tests/baselines/reference/restParameterWithBindingPattern3.symbols

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,18 @@ function a(...[a = 1, b = true]: string[]) { }
44
>a : Symbol(a, Decl(restParameterWithBindingPattern3.ts, 0, 15))
55
>b : Symbol(b, Decl(restParameterWithBindingPattern3.ts, 0, 21))
66

7+
function b(...[...foo = []]: string[]) { }
8+
>b : Symbol(b, Decl(restParameterWithBindingPattern3.ts, 0, 46))
9+
>foo : Symbol(foo, Decl(restParameterWithBindingPattern3.ts, 2, 15))
10+
11+
function c(...{0: a, length, 3: d}: [boolean, string, number]) { }
12+
>c : Symbol(c, Decl(restParameterWithBindingPattern3.ts, 2, 42))
13+
>a : Symbol(a, Decl(restParameterWithBindingPattern3.ts, 4, 15))
14+
>length : Symbol(length, Decl(restParameterWithBindingPattern3.ts, 4, 20))
15+
>d : Symbol(d, Decl(restParameterWithBindingPattern3.ts, 4, 28))
16+
17+
function d(...[a, , , d]: [boolean, string, number]) { }
18+
>d : Symbol(d, Decl(restParameterWithBindingPattern3.ts, 4, 66))
19+
>a : Symbol(a, Decl(restParameterWithBindingPattern3.ts, 6, 15))
20+
>d : Symbol(d, Decl(restParameterWithBindingPattern3.ts, 6, 21))
21+

tests/baselines/reference/restParameterWithBindingPattern3.types

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,21 @@ function a(...[a = 1, b = true]: string[]) { }
66
>b : string
77
>true : true
88

9+
function b(...[...foo = []]: string[]) { }
10+
>b : (...[...foo]: string[]) => void
11+
>foo : string[]
12+
>[] : undefined[]
13+
14+
function c(...{0: a, length, 3: d}: [boolean, string, number]) { }
15+
>c : (__0_0: boolean, __0_1: string, __0_2: number) => void
16+
>a : boolean
17+
>length : 3
18+
>d : string | number | boolean
19+
20+
function d(...[a, , , d]: [boolean, string, number]) { }
21+
>d : (__0_0: boolean, __0_1: string, __0_2: number) => void
22+
>a : boolean
23+
> : undefined
24+
> : undefined
25+
>d : any
26+

tests/baselines/reference/restParameterWithBindingPattern4.errors.txt

Lines changed: 0 additions & 7 deletions
This file was deleted.

tests/baselines/reference/restParameterWithBindingPattern4.js

Lines changed: 0 additions & 11 deletions
This file was deleted.

tests/baselines/reference/restParameterWithBindingPattern4.symbols

Lines changed: 0 additions & 5 deletions
This file was deleted.

tests/baselines/reference/restParameterWithBindingPattern4.types

Lines changed: 0 additions & 6 deletions
This file was deleted.

tests/baselines/reference/restParameterWithBindingPattern5.js

Lines changed: 0 additions & 11 deletions
This file was deleted.

tests/baselines/reference/restParameterWithBindingPattern5.symbols

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)