From 50eca44e46a85a9ac155deea7ef649802af9b10e Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Mon, 29 Feb 2016 18:55:32 -0800 Subject: [PATCH] Support JSDoc on class / obj. literal getters Fixes #6878 --- src/compiler/parser.ts | 2 +- .../fourslash/getJavaScriptQuickInfo7.ts | 34 +++++++++++-------- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index db9639156a5..e7e45a19a93 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -3954,7 +3954,7 @@ namespace ts { function tryParseAccessorDeclaration(fullStart: number, decorators: NodeArray, modifiers: ModifiersArray): AccessorDeclaration { if (parseContextualModifier(SyntaxKind.GetKeyword)) { - return parseAccessorDeclaration(SyntaxKind.GetAccessor, fullStart, decorators, modifiers); + return addJSDocComment(parseAccessorDeclaration(SyntaxKind.GetAccessor, fullStart, decorators, modifiers)); } else if (parseContextualModifier(SyntaxKind.SetKeyword)) { return parseAccessorDeclaration(SyntaxKind.SetAccessor, fullStart, decorators, modifiers); diff --git a/tests/cases/fourslash/getJavaScriptQuickInfo7.ts b/tests/cases/fourslash/getJavaScriptQuickInfo7.ts index 5aa8474757d..2c8e40131e5 100644 --- a/tests/cases/fourslash/getJavaScriptQuickInfo7.ts +++ b/tests/cases/fourslash/getJavaScriptQuickInfo7.ts @@ -2,19 +2,25 @@ // @allowNonTsExtensions: true // @Filename: file.js -//// /** -//// * This is a very cool function that is very nice. -//// * @returns something -//// * @param p anotherthing -//// */ -//// function a1(p) { -//// try { -//// throw new Error('x'); -//// } catch (x) { x--; } -//// return 23; +//// let x = { +//// /** This is cool*/ +//// get m() { +//// return 0; +//// } //// } -//// -//// x - /**/a1() +//// x.m/*1*/; +//// +//// class Foo { +//// /** This is cool too*/ +//// get b() { +//// return 0; +//// } +//// } +//// var y = new Foo(); +//// y.b/*2*/; -goTo.marker(); -verify.quickInfoExists(); \ No newline at end of file +goTo.marker('1'); +verify.quickInfoIs(undefined, 'This is cool'); + +goTo.marker('2'); +verify.quickInfoIs(undefined, 'This is cool too');