From a275dabe44f1e58fb7676b963190dd70cd729ab6 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Mon, 16 Nov 2015 16:48:57 -0800 Subject: [PATCH] When constructing signature, include parameter symbol instead of property symbol of parameter-property declaration Fixes #4566 --- src/compiler/checker.ts | 8 +++++++- ...natureHelpConstructorCallParamProperties.ts | 18 ++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 tests/cases/fourslash/signatureHelpConstructorCallParamProperties.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index f975c110b03..378fd85265f 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -3829,7 +3829,13 @@ namespace ts { let minArgumentCount = -1; for (let i = 0, n = declaration.parameters.length; i < n; i++) { const param = declaration.parameters[i]; - parameters.push(param.symbol); + let paramSymbol = param.symbol; + // Include parameter symbol instead of property symbol in the signature + if (paramSymbol && !!(paramSymbol.flags & SymbolFlags.Property) && !isBindingPattern(param.name)) { + const resolvedSymbol = resolveName(param, paramSymbol.name, SymbolFlags.Value, undefined, undefined); + paramSymbol = resolvedSymbol; + } + parameters.push(paramSymbol); if (param.type && param.type.kind === SyntaxKind.StringLiteral) { hasStringLiterals = true; } diff --git a/tests/cases/fourslash/signatureHelpConstructorCallParamProperties.ts b/tests/cases/fourslash/signatureHelpConstructorCallParamProperties.ts new file mode 100644 index 00000000000..aab276403fe --- /dev/null +++ b/tests/cases/fourslash/signatureHelpConstructorCallParamProperties.ts @@ -0,0 +1,18 @@ +/// + +////class Circle { +//// /** +//// * Initialize a circle. +//// * @param radius The radius of the circle. +//// */ +//// constructor(private radius: number) { +//// } +////} +////var a = new Circle(/**/ + +goTo.marker(''); +verify.signatureHelpCountIs(1); +verify.currentSignatureHelpIs("Circle(radius: number): Circle"); +verify.currentParameterHelpArgumentNameIs("radius"); +verify.currentParameterSpanIs("radius: number"); +verify.currentParameterHelpArgumentDocCommentIs("The radius of the circle."); \ No newline at end of file