Skip to content

Commit ed48e58

Browse files
author
Andy Hanson
committed
Fix test
1 parent 693cb9c commit ed48e58

8 files changed

+82
-55
lines changed

tests/baselines/reference/trailingCommasInFunctionParametersAndArguments.errors.txt

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

tests/baselines/reference/trailingCommasInFunctionParametersAndArguments.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//// [trailingCommasInFunctionParametersAndArguments.ts]
2+
23
function f1(x,) {}
34

45
f1(1,);
@@ -17,8 +18,7 @@ declare function f3(x, y,): string;
1718
// Works for constructors too
1819
class X {
1920
constructor(a,) { }
20-
// *Not* allowed in getter
21-
get x(,) { return 0; }
21+
// See trailingCommasInGetter.ts
2222
set x(value,) { }
2323
}
2424
interface Y {
@@ -46,8 +46,7 @@ var X = (function () {
4646
function X(a) {
4747
}
4848
Object.defineProperty(X.prototype, "x", {
49-
// *Not* allowed in getter
50-
get: function () { return 0; },
49+
// See trailingCommasInGetter.ts
5150
set: function (value) { },
5251
enumerable: true,
5352
configurable: true
Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,57 @@
11
=== tests/cases/conformance/es7/trailingCommasInFunctionParametersAndArguments.ts ===
2+
23
function f1(x,) {}
34
>f1 : Symbol(f1, Decl(trailingCommasInFunctionParametersAndArguments.ts, 0, 0))
4-
>x : Symbol(x, Decl(trailingCommasInFunctionParametersAndArguments.ts, 0, 12))
5+
>x : Symbol(x, Decl(trailingCommasInFunctionParametersAndArguments.ts, 1, 12))
56

67
f1(1,);
78
>f1 : Symbol(f1, Decl(trailingCommasInFunctionParametersAndArguments.ts, 0, 0))
89

910
function f2(...args,) {}
10-
>f2 : Symbol(f2, Decl(trailingCommasInFunctionParametersAndArguments.ts, 2, 7))
11-
>args : Symbol(args, Decl(trailingCommasInFunctionParametersAndArguments.ts, 4, 12))
11+
>f2 : Symbol(f2, Decl(trailingCommasInFunctionParametersAndArguments.ts, 3, 7))
12+
>args : Symbol(args, Decl(trailingCommasInFunctionParametersAndArguments.ts, 5, 12))
1213

1314
f2(...[],);
14-
>f2 : Symbol(f2, Decl(trailingCommasInFunctionParametersAndArguments.ts, 2, 7))
15+
>f2 : Symbol(f2, Decl(trailingCommasInFunctionParametersAndArguments.ts, 3, 7))
1516

1617
// Not confused by overloads
1718
declare function f3(x, ): number;
18-
>f3 : Symbol(f3, Decl(trailingCommasInFunctionParametersAndArguments.ts, 6, 11), Decl(trailingCommasInFunctionParametersAndArguments.ts, 9, 33))
19-
>x : Symbol(x, Decl(trailingCommasInFunctionParametersAndArguments.ts, 9, 20))
19+
>f3 : Symbol(f3, Decl(trailingCommasInFunctionParametersAndArguments.ts, 7, 11), Decl(trailingCommasInFunctionParametersAndArguments.ts, 10, 33))
20+
>x : Symbol(x, Decl(trailingCommasInFunctionParametersAndArguments.ts, 10, 20))
2021

2122
declare function f3(x, y,): string;
22-
>f3 : Symbol(f3, Decl(trailingCommasInFunctionParametersAndArguments.ts, 6, 11), Decl(trailingCommasInFunctionParametersAndArguments.ts, 9, 33))
23-
>x : Symbol(x, Decl(trailingCommasInFunctionParametersAndArguments.ts, 10, 20))
24-
>y : Symbol(y, Decl(trailingCommasInFunctionParametersAndArguments.ts, 10, 22))
23+
>f3 : Symbol(f3, Decl(trailingCommasInFunctionParametersAndArguments.ts, 7, 11), Decl(trailingCommasInFunctionParametersAndArguments.ts, 10, 33))
24+
>x : Symbol(x, Decl(trailingCommasInFunctionParametersAndArguments.ts, 11, 20))
25+
>y : Symbol(y, Decl(trailingCommasInFunctionParametersAndArguments.ts, 11, 22))
2526

2627
<number>f3(1,);
27-
>f3 : Symbol(f3, Decl(trailingCommasInFunctionParametersAndArguments.ts, 6, 11), Decl(trailingCommasInFunctionParametersAndArguments.ts, 9, 33))
28+
>f3 : Symbol(f3, Decl(trailingCommasInFunctionParametersAndArguments.ts, 7, 11), Decl(trailingCommasInFunctionParametersAndArguments.ts, 10, 33))
2829

2930
<string>f3(1, 2,);
30-
>f3 : Symbol(f3, Decl(trailingCommasInFunctionParametersAndArguments.ts, 6, 11), Decl(trailingCommasInFunctionParametersAndArguments.ts, 9, 33))
31+
>f3 : Symbol(f3, Decl(trailingCommasInFunctionParametersAndArguments.ts, 7, 11), Decl(trailingCommasInFunctionParametersAndArguments.ts, 10, 33))
3132

3233
// Works for constructors too
3334
class X {
34-
>X : Symbol(X, Decl(trailingCommasInFunctionParametersAndArguments.ts, 13, 18))
35+
>X : Symbol(X, Decl(trailingCommasInFunctionParametersAndArguments.ts, 14, 18))
3536

3637
constructor(a,) { }
37-
>a : Symbol(a, Decl(trailingCommasInFunctionParametersAndArguments.ts, 17, 16))
38+
>a : Symbol(a, Decl(trailingCommasInFunctionParametersAndArguments.ts, 18, 16))
39+
40+
// See trailingCommasInGetter.ts
41+
set x(value,) { }
42+
>x : Symbol(X.x, Decl(trailingCommasInFunctionParametersAndArguments.ts, 18, 23))
43+
>value : Symbol(value, Decl(trailingCommasInFunctionParametersAndArguments.ts, 20, 10))
3844
}
45+
interface Y {
46+
>Y : Symbol(Y, Decl(trailingCommasInFunctionParametersAndArguments.ts, 21, 1))
47+
48+
new(x,);
49+
>x : Symbol(x, Decl(trailingCommasInFunctionParametersAndArguments.ts, 23, 8))
50+
51+
(x,);
52+
>x : Symbol(x, Decl(trailingCommasInFunctionParametersAndArguments.ts, 24, 5))
53+
}
54+
3955
new X(1,);
40-
>X : Symbol(X, Decl(trailingCommasInFunctionParametersAndArguments.ts, 13, 18))
56+
>X : Symbol(X, Decl(trailingCommasInFunctionParametersAndArguments.ts, 14, 18))
4157

tests/baselines/reference/trailingCommasInFunctionParametersAndArguments.types

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
=== tests/cases/conformance/es7/trailingCommasInFunctionParametersAndArguments.ts ===
2+
23
function f1(x,) {}
34
>f1 : (x: any) => void
45
>x : any
@@ -47,7 +48,22 @@ class X {
4748

4849
constructor(a,) { }
4950
>a : any
51+
52+
// See trailingCommasInGetter.ts
53+
set x(value,) { }
54+
>x : any
55+
>value : any
5056
}
57+
interface Y {
58+
>Y : Y
59+
60+
new(x,);
61+
>x : any
62+
63+
(x,);
64+
>x : any
65+
}
66+
5167
new X(1,);
5268
>new X(1,) : X
5369
>X : typeof X
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
tests/cases/conformance/es7/trailingCommasInGetter.ts(2,11): error TS1138: Parameter declaration expected.
2+
3+
4+
==== tests/cases/conformance/es7/trailingCommasInGetter.ts (1 errors) ====
5+
class X {
6+
get x(,) { return 0; }
7+
~
8+
!!! error TS1138: Parameter declaration expected.
9+
}
10+
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//// [trailingCommasInGetter.ts]
2+
class X {
3+
get x(,) { return 0; }
4+
}
5+
6+
7+
//// [trailingCommasInGetter.js]
8+
var X = (function () {
9+
function X() {
10+
}
11+
Object.defineProperty(X.prototype, "x", {
12+
get: function () { return 0; },
13+
enumerable: true,
14+
configurable: true
15+
});
16+
return X;
17+
}());

tests/cases/conformance/es7/trailingCommasInFunctionParametersAndArguments.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// @target: es5
2+
13
function f1(x,) {}
24

35
f1(1,);
@@ -16,8 +18,7 @@ declare function f3(x, y,): string;
1618
// Works for constructors too
1719
class X {
1820
constructor(a,) { }
19-
// *Not* allowed in getter
20-
get x(,) { return 0; }
21+
// See trailingCommasInGetter.ts
2122
set x(value,) { }
2223
}
2324
interface Y {
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
class X {
2+
get x(,) { return 0; }
3+
}

0 commit comments

Comments
 (0)