From 1b282cda1de630186e9ad4aa20f30dfd66bb9c9b Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Wed, 27 Jan 2016 14:07:32 -0800 Subject: [PATCH] Parse JSDoc comments for ES6 class constructors and methods Fixes #6646 --- src/compiler/parser.ts | 4 ++-- .../fourslash/getJavaScriptCompletions16.ts | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 tests/cases/fourslash/getJavaScriptCompletions16.ts diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 57bd9860d12..1ee74603825 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -4778,7 +4778,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 { @@ -4792,7 +4792,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..07c50d3f892 --- /dev/null +++ b/tests/cases/fourslash/getJavaScriptCompletions16.ts @@ -0,0 +1,18 @@ +/// + +// @allowNonTsExtensions: true +// @Filename: file.js +//// "use strict"; +//// +//// class Something { +//// +//// /** +//// * @param {number} a +//// */ +//// constructor(a, b) { +//// a./**/ +//// } +//// } + +goTo.marker(); +verify.completionListContains('toFixed', undefined, undefined, 'method');