Merge pull request #30084 from dragomirtitian/GH-26563
Improved argument description for parameters originating from tuples
This commit is contained in:
commit
d0646a629a
4 changed files with 59 additions and 1 deletions
|
@ -232,6 +232,7 @@ namespace ts {
|
|||
getResolvedSignatureForSignatureHelp: (node, candidatesOutArray, agumentCount) =>
|
||||
getResolvedSignatureWorker(node, candidatesOutArray, agumentCount, CheckMode.IsForSignatureHelp),
|
||||
getExpandedParameters,
|
||||
hasEffectiveRestParameter,
|
||||
getConstantValue: nodeIn => {
|
||||
const node = getParseTreeNode(nodeIn, canHaveConstantValue);
|
||||
return node ? getConstantValue(node) : undefined;
|
||||
|
|
|
@ -3171,6 +3171,7 @@ namespace ts {
|
|||
getResolvedSignature(node: CallLikeExpression, candidatesOutArray?: Signature[], argumentCount?: number): Signature | undefined;
|
||||
/* @internal */ getResolvedSignatureForSignatureHelp(node: CallLikeExpression, candidatesOutArray?: Signature[], argumentCount?: number): Signature | undefined;
|
||||
/* @internal */ getExpandedParameters(sig: Signature): ReadonlyArray<Symbol>;
|
||||
/* @internal */ hasEffectiveRestParameter(sig: Signature): boolean;
|
||||
getSignatureFromDeclaration(declaration: SignatureDeclaration): Signature | undefined;
|
||||
isImplementationOfOverload(node: SignatureDeclaration): boolean | undefined;
|
||||
isUndefinedSymbol(symbol: Symbol): boolean;
|
||||
|
|
|
@ -566,7 +566,7 @@ namespace ts.SignatureHelp {
|
|||
}
|
||||
|
||||
function itemInfoForParameters(candidateSignature: Signature, checker: TypeChecker, enclosingDeclaration: Node, sourceFile: SourceFile): SignatureHelpItemInfo {
|
||||
const isVariadic = candidateSignature.hasRestParameter;
|
||||
const isVariadic = checker.hasEffectiveRestParameter(candidateSignature);
|
||||
const printer = createPrinter({ removeComments: true });
|
||||
const typeParameterParts = mapToDisplayParts(writer => {
|
||||
if (candidateSignature.typeParameters && candidateSignature.typeParameters.length) {
|
||||
|
|
56
tests/cases/fourslash/signatureHelpCallExpressionTuples.ts
Normal file
56
tests/cases/fourslash/signatureHelpCallExpressionTuples.ts
Normal file
|
@ -0,0 +1,56 @@
|
|||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
|
||||
//// function fnTest(str: string, num: number) { }
|
||||
//// declare function wrap<A extends any[], R>(fn: (...a: A) => R) : (...a: A) => R;
|
||||
//// var fnWrapped = wrap(fnTest);
|
||||
//// fnWrapped/*3*/(/*1*/'', /*2*/5);
|
||||
//// function fnTestVariadic (str: string, ...num: number[]) { }
|
||||
//// var fnVariadicWrapped = wrap(fnTestVariadic);
|
||||
//// fnVariadicWrapped/*4*/(/*5*/'', /*6*/5);
|
||||
//// function fnNoParams () { }
|
||||
//// var fnNoParamsWrapped = wrap(fnNoParams);
|
||||
//// fnNoParamsWrapped/*7*/(/*8*/);
|
||||
|
||||
verify.quickInfoAt("3", "var fnWrapped: (str: string, num: number) => void");
|
||||
verify.signatureHelp(
|
||||
{
|
||||
marker: "1",
|
||||
text: "fnWrapped(str: string, num: number): void",
|
||||
parameterCount: 2,
|
||||
parameterName: "str",
|
||||
parameterSpan: "str: string",
|
||||
},
|
||||
{
|
||||
marker: "2",
|
||||
parameterName: "num",
|
||||
parameterSpan: "num: number",
|
||||
},
|
||||
);
|
||||
|
||||
verify.quickInfoAt("4", "var fnVariadicWrapped: (str: string, ...num: number[]) => void");
|
||||
verify.signatureHelp(
|
||||
{
|
||||
marker: "5",
|
||||
text: "fnVariadicWrapped(str: string, ...num: number[]): void",
|
||||
parameterCount: 2,
|
||||
parameterName: "str",
|
||||
parameterSpan: "str: string",
|
||||
isVariadic: true,
|
||||
},
|
||||
{
|
||||
marker: "6",
|
||||
parameterName: "num",
|
||||
parameterSpan: "...num: number[]",
|
||||
isVariadic: true,
|
||||
},
|
||||
);
|
||||
|
||||
verify.quickInfoAt("7", "var fnNoParamsWrapped: () => void");
|
||||
verify.signatureHelp(
|
||||
{
|
||||
marker: "8",
|
||||
text: "fnNoParamsWrapped(): void",
|
||||
parameterCount: 0,
|
||||
}
|
||||
);
|
Loading…
Reference in a new issue