Fix signature help

This commit is contained in:
Andy Hanson
2016-06-06 07:50:32 -07:00
parent 8b0974a77e
commit 2fc2f5c4b9
5 changed files with 107 additions and 6 deletions

View File

@@ -6,6 +6,19 @@ 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,) { }
}
new X(1,);
//// [trailingCommasInFunctionParametersAndArguments.js]
@@ -18,3 +31,12 @@ function f2() {
}
}
f2.apply(void 0, []);
f3(1);
f3(1, 2);
// Works for constructors too
var X = (function () {
function X(a) {
}
return X;
}());
new X(1);

View File

@@ -13,3 +13,29 @@ function f2(...args,) {}
f2(...[],);
>f2 : Symbol(f2, Decl(trailingCommasInFunctionParametersAndArguments.ts, 2, 7))
// Not confused by overloads
declare function f3(x, ): number;
>f3 : Symbol(f3, Decl(trailingCommasInFunctionParametersAndArguments.ts, 6, 11), Decl(trailingCommasInFunctionParametersAndArguments.ts, 9, 33))
>x : Symbol(x, Decl(trailingCommasInFunctionParametersAndArguments.ts, 9, 20))
declare function f3(x, y,): string;
>f3 : Symbol(f3, Decl(trailingCommasInFunctionParametersAndArguments.ts, 6, 11), Decl(trailingCommasInFunctionParametersAndArguments.ts, 9, 33))
>x : Symbol(x, Decl(trailingCommasInFunctionParametersAndArguments.ts, 10, 20))
>y : Symbol(y, Decl(trailingCommasInFunctionParametersAndArguments.ts, 10, 22))
<number>f3(1,);
>f3 : Symbol(f3, Decl(trailingCommasInFunctionParametersAndArguments.ts, 6, 11), Decl(trailingCommasInFunctionParametersAndArguments.ts, 9, 33))
<string>f3(1, 2,);
>f3 : Symbol(f3, Decl(trailingCommasInFunctionParametersAndArguments.ts, 6, 11), Decl(trailingCommasInFunctionParametersAndArguments.ts, 9, 33))
// Works for constructors too
class X {
>X : Symbol(X, Decl(trailingCommasInFunctionParametersAndArguments.ts, 13, 18))
constructor(a,) { }
>a : Symbol(a, Decl(trailingCommasInFunctionParametersAndArguments.ts, 17, 16))
}
new X(1,);
>X : Symbol(X, Decl(trailingCommasInFunctionParametersAndArguments.ts, 13, 18))

View File

@@ -18,3 +18,38 @@ f2(...[],);
>...[] : 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 : number
<string>f3(1, 2,);
><string>f3(1, 2,) : string
>f3(1, 2,) : string
>f3 : { (x: any): number; (x: any, y: any): string; }
>1 : number
>2 : number
// Works for constructors too
class X {
>X : X
constructor(a,) { }
>a : any
}
new X(1,);
>new X(1,) : X
>X : typeof X
>1 : number

View File

@@ -5,3 +5,16 @@ 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,) { }
}
new X(1,);