Skip to content

Commit 693cb9c

Browse files
author
Andy Hanson
committed
Add additional tests
1 parent 2fc2f5c commit 693cb9c

File tree

3 files changed

+58
-0
lines changed

3 files changed

+58
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
tests/cases/conformance/es7/trailingCommasInFunctionParametersAndArguments.ts(20,11): error TS1138: Parameter declaration expected.
2+
3+
4+
==== tests/cases/conformance/es7/trailingCommasInFunctionParametersAndArguments.ts (1 errors) ====
5+
function f1(x,) {}
6+
7+
f1(1,);
8+
9+
function f2(...args,) {}
10+
11+
f2(...[],);
12+
13+
// Not confused by overloads
14+
declare function f3(x, ): number;
15+
declare function f3(x, y,): string;
16+
17+
<number>f3(1,);
18+
<string>f3(1, 2,);
19+
20+
// Works for constructors too
21+
class X {
22+
constructor(a,) { }
23+
// *Not* allowed in getter
24+
get x(,) { return 0; }
25+
~
26+
!!! error TS1138: Parameter declaration expected.
27+
set x(value,) { }
28+
}
29+
interface Y {
30+
new(x,);
31+
(x,);
32+
}
33+
34+
new X(1,);
35+

tests/baselines/reference/trailingCommasInFunctionParametersAndArguments.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,15 @@ declare function f3(x, y,): string;
1717
// Works for constructors too
1818
class X {
1919
constructor(a,) { }
20+
// *Not* allowed in getter
21+
get x(,) { return 0; }
22+
set x(value,) { }
2023
}
24+
interface Y {
25+
new(x,);
26+
(x,);
27+
}
28+
2129
new X(1,);
2230

2331

@@ -37,6 +45,13 @@ f3(1, 2);
3745
var X = (function () {
3846
function X(a) {
3947
}
48+
Object.defineProperty(X.prototype, "x", {
49+
// *Not* allowed in getter
50+
get: function () { return 0; },
51+
set: function (value) { },
52+
enumerable: true,
53+
configurable: true
54+
});
4055
return X;
4156
}());
4257
new X(1);

tests/cases/conformance/es7/trailingCommasInFunctionParametersAndArguments.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,13 @@ declare function f3(x, y,): string;
1616
// Works for constructors too
1717
class X {
1818
constructor(a,) { }
19+
// *Not* allowed in getter
20+
get x(,) { return 0; }
21+
set x(value,) { }
1922
}
23+
interface Y {
24+
new(x,);
25+
(x,);
26+
}
27+
2028
new X(1,);

0 commit comments

Comments
 (0)