Skip to content

Commit 50eca44

Browse files
committed
Support JSDoc on class / obj. literal getters
Fixes microsoft#6878
1 parent 8a72229 commit 50eca44

File tree

2 files changed

+21
-15
lines changed

2 files changed

+21
-15
lines changed

src/compiler/parser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3954,7 +3954,7 @@ namespace ts {
39543954

39553955
function tryParseAccessorDeclaration(fullStart: number, decorators: NodeArray<Decorator>, modifiers: ModifiersArray): AccessorDeclaration {
39563956
if (parseContextualModifier(SyntaxKind.GetKeyword)) {
3957-
return parseAccessorDeclaration(SyntaxKind.GetAccessor, fullStart, decorators, modifiers);
3957+
return addJSDocComment(parseAccessorDeclaration(SyntaxKind.GetAccessor, fullStart, decorators, modifiers));
39583958
}
39593959
else if (parseContextualModifier(SyntaxKind.SetKeyword)) {
39603960
return parseAccessorDeclaration(SyntaxKind.SetAccessor, fullStart, decorators, modifiers);

tests/cases/fourslash/getJavaScriptQuickInfo7.ts

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,25 @@
22

33
// @allowNonTsExtensions: true
44
// @Filename: file.js
5-
//// /**
6-
//// * This is a very cool function that is very nice.
7-
//// * @returns something
8-
//// * @param p anotherthing
9-
//// */
10-
//// function a1(p) {
11-
//// try {
12-
//// throw new Error('x');
13-
//// } catch (x) { x--; }
14-
//// return 23;
5+
//// let x = {
6+
//// /** This is cool*/
7+
//// get m() {
8+
//// return 0;
9+
//// }
1510
//// }
16-
////
17-
//// x - /**/a1()
11+
//// x.m/*1*/;
12+
////
13+
//// class Foo {
14+
//// /** This is cool too*/
15+
//// get b() {
16+
//// return 0;
17+
//// }
18+
//// }
19+
//// var y = new Foo();
20+
//// y.b/*2*/;
21+
22+
goTo.marker('1');
23+
verify.quickInfoIs(undefined, 'This is cool');
1824

19-
goTo.marker();
20-
verify.quickInfoExists();
25+
goTo.marker('2');
26+
verify.quickInfoIs(undefined, 'This is cool too');

0 commit comments

Comments
 (0)