mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-19 20:37:00 -05:00
Add additional tests
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
tests/cases/conformance/es7/trailingCommasInFunctionParametersAndArguments.ts(20,11): error TS1138: Parameter declaration expected.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es7/trailingCommasInFunctionParametersAndArguments.ts (1 errors) ====
|
||||
function f1(x,) {}
|
||||
|
||||
f1(1,);
|
||||
|
||||
function f2(...args,) {}
|
||||
|
||||
f2(...[],);
|
||||
|
||||
// Not confused by overloads
|
||||
declare function f3(x, ): number;
|
||||
declare function f3(x, y,): string;
|
||||
|
||||
<number>f3(1,);
|
||||
<string>f3(1, 2,);
|
||||
|
||||
// Works for constructors too
|
||||
class X {
|
||||
constructor(a,) { }
|
||||
// *Not* allowed in getter
|
||||
get x(,) { return 0; }
|
||||
~
|
||||
!!! error TS1138: Parameter declaration expected.
|
||||
set x(value,) { }
|
||||
}
|
||||
interface Y {
|
||||
new(x,);
|
||||
(x,);
|
||||
}
|
||||
|
||||
new X(1,);
|
||||
|
||||
@@ -17,7 +17,15 @@ declare function f3(x, y,): string;
|
||||
// Works for constructors too
|
||||
class X {
|
||||
constructor(a,) { }
|
||||
// *Not* allowed in getter
|
||||
get x(,) { return 0; }
|
||||
set x(value,) { }
|
||||
}
|
||||
interface Y {
|
||||
new(x,);
|
||||
(x,);
|
||||
}
|
||||
|
||||
new X(1,);
|
||||
|
||||
|
||||
@@ -37,6 +45,13 @@ f3(1, 2);
|
||||
var X = (function () {
|
||||
function X(a) {
|
||||
}
|
||||
Object.defineProperty(X.prototype, "x", {
|
||||
// *Not* allowed in getter
|
||||
get: function () { return 0; },
|
||||
set: function (value) { },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
return X;
|
||||
}());
|
||||
new X(1);
|
||||
|
||||
@@ -16,5 +16,13 @@ declare function f3(x, y,): string;
|
||||
// Works for constructors too
|
||||
class X {
|
||||
constructor(a,) { }
|
||||
// *Not* allowed in getter
|
||||
get x(,) { return 0; }
|
||||
set x(value,) { }
|
||||
}
|
||||
interface Y {
|
||||
new(x,);
|
||||
(x,);
|
||||
}
|
||||
|
||||
new X(1,);
|
||||
|
||||
Reference in New Issue
Block a user