Skip to content

Commit

Permalink
(signature help) type parameter lists are never variadic (#12112)
Browse files Browse the repository at this point in the history
  • Loading branch information
vladima authored Nov 9, 2016
1 parent 9a9f45f commit 28cc938
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
10 changes: 9 additions & 1 deletion src/harness/fourslash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1026,7 +1026,7 @@ namespace FourSlash {
ts.displayPartsToString(help.suffixDisplayParts), expected);
}

public verifyCurrentParameterIsletiable(isVariable: boolean) {
public verifyCurrentParameterIsVariable(isVariable: boolean) {
const signature = this.getActiveSignatureHelpItem();
assert.isOk(signature);
assert.equal(isVariable, signature.isVariadic);
Expand All @@ -1053,6 +1053,10 @@ namespace FourSlash {
assert.equal(this.getActiveSignatureHelpItem().parameters.length, expectedCount);
}

public verifyCurrentSignatureHelpIsVariadic(expected: boolean) {
assert.equal(this.getActiveSignatureHelpItem().isVariadic, expected);
}

public verifyCurrentSignatureHelpDocComment(docComment: string) {
const actualDocComment = this.getActiveSignatureHelpItem().documentation;
assert.equal(ts.displayPartsToString(actualDocComment), docComment, this.assertionMessageAtLastKnownMarker("current signature help doc comment"));
Expand Down Expand Up @@ -3231,6 +3235,10 @@ namespace FourSlashInterface {
this.state.verifySignatureHelpCount(expected);
}

public signatureHelpCurrentArgumentListIsVariadic(expected: boolean) {
this.state.verifyCurrentSignatureHelpIsVariadic(expected);
}

public signatureHelpArgumentCountIs(expected: number) {
this.state.verifySignatureHelpArgumentCount(expected);
}
Expand Down
5 changes: 4 additions & 1 deletion src/services/signatureHelp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,9 @@ namespace ts.SignatureHelp {
addRange(prefixDisplayParts, callTargetDisplayParts);
}

let isVariadic: boolean;
if (isTypeParameterList) {
isVariadic = false; // type parameter lists are not variadic
prefixDisplayParts.push(punctuationPart(SyntaxKind.LessThanToken));
const typeParameters = candidateSignature.typeParameters;
signatureHelpParameters = typeParameters && typeParameters.length > 0 ? map(typeParameters, createSignatureHelpParameterForTypeParameter) : emptyArray;
Expand All @@ -567,6 +569,7 @@ namespace ts.SignatureHelp {
addRange(suffixDisplayParts, parameterParts);
}
else {
isVariadic = candidateSignature.hasRestParameter;
const typeParameterParts = mapToDisplayParts(writer =>
typeChecker.getSymbolDisplayBuilder().buildDisplayForTypeParametersAndDelimiters(candidateSignature.typeParameters, writer, invocation));
addRange(prefixDisplayParts, typeParameterParts);
Expand All @@ -582,7 +585,7 @@ namespace ts.SignatureHelp {
addRange(suffixDisplayParts, returnTypeParts);

return {
isVariadic: candidateSignature.hasRestParameter,
isVariadic,
prefixDisplayParts,
suffixDisplayParts,
separatorDisplayParts: [punctuationPart(SyntaxKind.CommaToken), spacePart()],
Expand Down
1 change: 1 addition & 0 deletions tests/cases/fourslash/fourslash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ declare namespace FourSlashInterface {
currentSignatureHelpDocCommentIs(docComment: string): void;
signatureHelpCountIs(expected: number): void;
signatureHelpArgumentCountIs(expected: number): void;
signatureHelpCurrentArgumentListIsVariadic(expected: boolean);
currentSignatureParameterCountIs(expected: number): void;
currentSignatureTypeParameterCountIs(expected: number): void;
currentSignatureHelpIs(expected: string): void;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/// <reference path="fourslash.ts" />

//// declare function f(a: any, ...b: any[]): any;
//// f</*1*/>(1, 2);

goTo.marker("1");
verify.signatureHelpArgumentCountIs(0);
verify.signatureHelpCurrentArgumentListIsVariadic(false);

0 comments on commit 28cc938

Please sign in to comment.