1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
|
//// [trailingCommasInFunctionParametersAndArguments.ts]
function f1(x,) {}
f1(1,);
function f2(...args,) {}
// Allowed for ambient declarations
declare function f25(...args,): void;
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,) { }
// See trailingCommasInGetter.ts
set x(value,) { }
}
interface Y {
new(x,);
(x,);
}
new X(1,);
//// [trailingCommasInFunctionParametersAndArguments.js]
function f1(x) { }
f1(1);
function f2() {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
}
f2.apply(void 0, []);
f3(1);
f3(1, 2);
// Works for constructors too
var X = /** @class */ (function () {
function X(a) {
}
Object.defineProperty(X.prototype, "x", {
// See trailingCommasInGetter.ts
set: function (value) { },
enumerable: true,
configurable: true
});
return X;
}());
new X(1);
|