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 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
|
=== tests/cases/conformance/es7/trailingCommasInFunctionParametersAndArguments.ts ===
function f1(x,) {}
>f1 : (x: any) => void
>x : any
f1(1,);
>f1(1,) : void
>f1 : (x: any) => void
>1 : 1
function f2(...args,) {}
>f2 : (...args: any[]) => void
>args : any[]
// Allowed for ambient declarations
declare function f25(...args,): void;
>f25 : (...args: any[]) => void
>args : any[]
f2(...[],);
>f2(...[],) : void
>f2 : (...args: any[]) => void
>...[] : undefined
>[] : undefined[]
// Not confused by overloads
declare function f3(x, ): number;
>f3 : { (x: any): number; (x: any, y: any): string; }
>x : any
declare function f3(x, y,): string;
>f3 : { (x: any): number; (x: any, y: any): string; }
>x : any
>y : any
<number>f3(1,);
><number>f3(1,) : number
>f3(1,) : number
>f3 : { (x: any): number; (x: any, y: any): string; }
>1 : 1
<string>f3(1, 2,);
><string>f3(1, 2,) : string
>f3(1, 2,) : string
>f3 : { (x: any): number; (x: any, y: any): string; }
>1 : 1
>2 : 2
// Works for constructors too
class X {
>X : X
constructor(a,) { }
>a : any
// See trailingCommasInGetter.ts
set x(value,) { }
>x : any
>value : any
}
interface Y {
new(x,);
>x : any
(x,);
>x : any
}
new X(1,);
>new X(1,) : X
>X : typeof X
>1 : 1
|