Skip to content

Commit 2d7a2f4

Browse files
committed
Merge pull request microsoft#6680 from RyanCavanaugh/fix6646
Parse JSDoc comments for ES6 class constructors and methods
2 parents 0855933 + 3dfd378 commit 2d7a2f4

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-2
lines changed

src/compiler/parser.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -4746,7 +4746,7 @@ namespace ts {
47464746
parseExpected(SyntaxKind.ConstructorKeyword);
47474747
fillSignature(SyntaxKind.ColonToken, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node);
47484748
node.body = parseFunctionBlockOrSemicolon(/*isGenerator*/ false, /*isAsync*/ false, Diagnostics.or_expected);
4749-
return finishNode(node);
4749+
return addJSDocComment(finishNode(node));
47504750
}
47514751

47524752
function parseMethodDeclaration(fullStart: number, decorators: NodeArray<Decorator>, modifiers: ModifiersArray, asteriskToken: Node, name: PropertyName, questionToken: Node, diagnosticMessage?: DiagnosticMessage): MethodDeclaration {
@@ -4760,7 +4760,7 @@ namespace ts {
47604760
const isAsync = !!(method.flags & NodeFlags.Async);
47614761
fillSignature(SyntaxKind.ColonToken, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, method);
47624762
method.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage);
4763-
return finishNode(method);
4763+
return addJSDocComment(finishNode(method));
47644764
}
47654765

47664766
function parsePropertyDeclaration(fullStart: number, decorators: NodeArray<Decorator>, modifiers: ModifiersArray, name: PropertyName, questionToken: Node): ClassElement {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/// <reference path="fourslash.ts" />
2+
3+
// @allowNonTsExtensions: true
4+
// @Filename: file.js
5+
//// "use strict";
6+
////
7+
//// class Something {
8+
////
9+
//// /**
10+
//// * @param {number} a
11+
//// */
12+
//// constructor(a, b) {
13+
//// a/*body*/
14+
//// }
15+
////
16+
//// /**
17+
//// * @param {number} a
18+
//// */
19+
//// method(a) {
20+
//// a/*method*/
21+
//// }
22+
//// }
23+
//// let x = new Something(/*sig*/);
24+
25+
goTo.marker('body');
26+
edit.insert('.');
27+
verify.completionListContains('toFixed', undefined, undefined, 'method');
28+
edit.backspace();
29+
30+
goTo.marker('sig');
31+
verify.currentSignatureHelpIs('Something(a: number, b: any): Something');
32+
33+
goTo.marker('method');
34+
edit.insert('.');
35+
verify.completionListContains('toFixed', undefined, undefined, 'method');

0 commit comments

Comments
 (0)