Skip to content

Commit cd2d5cd

Browse files
Property show variadic parameters for javascript functions.
1 parent 8564a8b commit cd2d5cd

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

src/compiler/checker.ts

+17-1
Original file line numberDiff line numberDiff line change
@@ -1738,8 +1738,24 @@ module ts {
17381738
}
17391739
}
17401740

1741+
function isVariadic(node: Node) {
1742+
if (node && node.kind === SyntaxKind.Parameter) {
1743+
let parameter = <ParameterDeclaration>node;
1744+
if (isFunctionLike(parameter.parent)) {
1745+
let functionParent = <FunctionLikeDeclaration>parameter.parent;
1746+
if (parameter === lastOrUndefined(functionParent.parameters) &&
1747+
hasRestParameters(functionParent)) {
1748+
1749+
return true;
1750+
}
1751+
}
1752+
1753+
return parameter.dotDotDotToken !== undefined;
1754+
}
1755+
}
1756+
17411757
function buildParameterDisplay(p: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, typeStack?: Type[]) {
1742-
if (hasDotDotDotToken(p.valueDeclaration)) {
1758+
if (isVariadic(p.valueDeclaration)) {
17431759
writePunctuation(writer, SyntaxKind.DotDotDotToken);
17441760
}
17451761
appendSymbolNameOnly(p, writer);

src/compiler/utilities.ts

-4
Original file line numberDiff line numberDiff line change
@@ -796,10 +796,6 @@ module ts {
796796
}
797797
}
798798

799-
export function hasDotDotDotToken(node: Node) {
800-
return node && node.kind === SyntaxKind.Parameter && (<ParameterDeclaration>node).dotDotDotToken !== undefined;
801-
}
802-
803799
export function hasQuestionToken(node: Node) {
804800
if (node) {
805801
switch (node.kind) {

0 commit comments

Comments
 (0)