mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-13 22:00:59 -05:00
Improved argument description for parameters originating from tuples that were extracted from functions. (ie mapped functions)
This commit is contained in:
@@ -112,6 +112,7 @@ namespace ts {
|
||||
getMergedSymbol,
|
||||
getDiagnostics,
|
||||
getGlobalDiagnostics,
|
||||
getExpandedParameters,
|
||||
getTypeOfSymbolAtLocation: (symbol, location) => {
|
||||
location = getParseTreeNode(location);
|
||||
return location ? getTypeOfSymbolAtLocation(symbol, location) : errorType;
|
||||
|
||||
@@ -3032,6 +3032,7 @@ namespace ts {
|
||||
/* @internal */
|
||||
getPromisedTypeOfPromise(promise: Type, errorNode?: Node): Type | undefined;
|
||||
getReturnTypeOfSignature(signature: Signature): Type;
|
||||
/* @internal */ getExpandedParameters(sig: Signature): ReadonlyArray<Symbol>;
|
||||
/**
|
||||
* Gets the type of a parameter at a given position in a signature.
|
||||
* Returns `any` if the index is not valid.
|
||||
|
||||
@@ -566,7 +566,7 @@ namespace ts.SignatureHelp {
|
||||
}
|
||||
|
||||
function itemInfoForParameters(candidateSignature: Signature, checker: TypeChecker, enclosingDeclaration: Node, sourceFile: SourceFile): SignatureHelpItemInfo {
|
||||
const isVariadic = candidateSignature.hasRestParameter;
|
||||
let isVariadic = candidateSignature.hasRestParameter;
|
||||
const printer = createPrinter({ removeComments: true });
|
||||
const typeParameterParts = mapToDisplayParts(writer => {
|
||||
if (candidateSignature.typeParameters && candidateSignature.typeParameters.length) {
|
||||
@@ -574,7 +574,16 @@ namespace ts.SignatureHelp {
|
||||
printer.writeList(ListFormat.TypeParameters, args, sourceFile, writer);
|
||||
}
|
||||
});
|
||||
const parameters = candidateSignature.parameters.map(p => createSignatureHelpParameterForParameter(p, checker, enclosingDeclaration, sourceFile, printer));
|
||||
|
||||
const expandedParameters = checker.getExpandedParameters(candidateSignature);
|
||||
const parameters = expandedParameters.map(p => createSignatureHelpParameterForParameter(p, checker, enclosingDeclaration, sourceFile, printer));
|
||||
|
||||
// If parameters are not the same as the expanded parameters, we need to reevaluate whether this a variadic signature based on the last parameter
|
||||
if (expandedParameters !== candidateSignature.parameters) {
|
||||
const restCandidate = lastOrUndefined(expandedParameters);
|
||||
isVariadic = !!restCandidate && !!(getCheckFlags(restCandidate) & CheckFlags.RestParameter);
|
||||
}
|
||||
|
||||
return { isVariadic, parameters, prefix: [...typeParameterParts, punctuationPart(SyntaxKind.OpenParenToken)], suffix: [punctuationPart(SyntaxKind.CloseParenToken)] };
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user