diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 4ec83277e3e..b6ba02b987c 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -4746,7 +4746,7 @@ namespace ts { parseExpected(SyntaxKind.ConstructorKeyword); fillSignature(SyntaxKind.ColonToken, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); node.body = parseFunctionBlockOrSemicolon(/*isGenerator*/ false, /*isAsync*/ false, Diagnostics.or_expected); - return finishNode(node); + return addJSDocComment(finishNode(node)); } function parseMethodDeclaration(fullStart: number, decorators: NodeArray, modifiers: ModifiersArray, asteriskToken: Node, name: PropertyName, questionToken: Node, diagnosticMessage?: DiagnosticMessage): MethodDeclaration { @@ -4760,7 +4760,7 @@ namespace ts { const isAsync = !!(method.flags & NodeFlags.Async); fillSignature(SyntaxKind.ColonToken, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, method); method.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage); - return finishNode(method); + return addJSDocComment(finishNode(method)); } function parsePropertyDeclaration(fullStart: number, decorators: NodeArray, modifiers: ModifiersArray, name: PropertyName, questionToken: Node): ClassElement { diff --git a/tests/cases/fourslash/getJavaScriptCompletions16.ts b/tests/cases/fourslash/getJavaScriptCompletions16.ts new file mode 100644 index 00000000000..4d4b76d98d6 --- /dev/null +++ b/tests/cases/fourslash/getJavaScriptCompletions16.ts @@ -0,0 +1,35 @@ +/// + +// @allowNonTsExtensions: true +// @Filename: file.js +//// "use strict"; +//// +//// class Something { +//// +//// /** +//// * @param {number} a +//// */ +//// constructor(a, b) { +//// a/*body*/ +//// } +//// +//// /** +//// * @param {number} a +//// */ +//// method(a) { +//// a/*method*/ +//// } +//// } +//// let x = new Something(/*sig*/); + +goTo.marker('body'); +edit.insert('.'); +verify.completionListContains('toFixed', undefined, undefined, 'method'); +edit.backspace(); + +goTo.marker('sig'); +verify.currentSignatureHelpIs('Something(a: number, b: any): Something'); + +goTo.marker('method'); +edit.insert('.'); +verify.completionListContains('toFixed', undefined, undefined, 'method');