Skip to content

Commit 8aad976

Browse files
committed
Recognize object literal method JSDoc comments
Fixes microsoft#6825
1 parent c69a9d1 commit 8aad976

File tree

3 files changed

+39
-2
lines changed

3 files changed

+39
-2
lines changed

src/compiler/parser.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3960,7 +3960,7 @@ namespace ts {
39603960
shorthandDeclaration.equalsToken = equalsToken;
39613961
shorthandDeclaration.objectAssignmentInitializer = allowInAnd(parseAssignmentExpressionOrHigher);
39623962
}
3963-
return finishNode(shorthandDeclaration);
3963+
return addJSDocComment(finishNode(shorthandDeclaration));
39643964
}
39653965
else {
39663966
const propertyAssignment = <PropertyAssignment>createNode(SyntaxKind.PropertyAssignment, fullStart);
@@ -3969,7 +3969,7 @@ namespace ts {
39693969
propertyAssignment.questionToken = questionToken;
39703970
parseExpected(SyntaxKind.ColonToken);
39713971
propertyAssignment.initializer = allowInAnd(parseAssignmentExpressionOrHigher);
3972-
return finishNode(propertyAssignment);
3972+
return addJSDocComment(finishNode(propertyAssignment));
39733973
}
39743974
}
39753975

src/compiler/utilities.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1220,6 +1220,11 @@ namespace ts {
12201220
if (isSourceOfAssignmentExpressionStatement) {
12211221
return node.parent.parent.jsDocComment;
12221222
}
1223+
1224+
const isPropertyAssignmentExpression = node.parent && node.parent.kind === SyntaxKind.PropertyAssignment;
1225+
if (isPropertyAssignmentExpression) {
1226+
return node.parent.jsDocComment;
1227+
}
12231228
}
12241229

12251230
return undefined;
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
///<reference path="fourslash.ts" />
2+
3+
// @allowNonTsExtensions: true
4+
// @Filename: Foo.js
5+
6+
//// var someObject = {
7+
//// /**
8+
//// * @param {string} param1 Some string param.
9+
//// * @param {number} parm2 Some number param.
10+
//// */
11+
//// someMethod: function(param1, param2) {
12+
//// console.log(param1/*1*/);
13+
//// return false;
14+
//// },
15+
//// /**
16+
//// * @param {number} p1 Some number param.
17+
//// */
18+
//// otherMethod(p1) {
19+
//// p1/*2*/
20+
//// }
21+
////
22+
//// };
23+
24+
goTo.marker('1');
25+
edit.insert('.');
26+
verify.memberListContains('substr', undefined, undefined, 'method');
27+
edit.backspace();
28+
29+
goTo.marker('2');
30+
edit.insert('.');
31+
verify.memberListContains('toFixed', undefined, undefined, 'method');
32+
edit.backspace();

0 commit comments

Comments
 (0)