Skip to content

Commit 758fc93

Browse files
committed
Declaration comments for accessors in .d.ts
1 parent 83ea28c commit 758fc93

File tree

5 files changed

+39
-2
lines changed

5 files changed

+39
-2
lines changed

src/compiler/emitter.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2041,8 +2041,10 @@ module ts {
20412041
}
20422042

20432043
function writeJsDocComments(declaration: Declaration) {
2044-
var jsDocComments = getJsDocComments(declaration, currentSourceFile);
2045-
emitComments(jsDocComments, writer, writeCommentRange);
2044+
if (declaration) {
2045+
var jsDocComments = getJsDocComments(declaration, currentSourceFile);
2046+
emitComments(jsDocComments, writer, writeCommentRange);
2047+
}
20462048
}
20472049

20482050
function emitSourceTextOfNode(node: Node) {
@@ -2459,6 +2461,8 @@ module ts {
24592461
function emitAccessorDeclaration(node: AccessorDeclaration) {
24602462
var accessors = getAllAccessorDeclarations(<ClassDeclaration>node.parent, node);
24612463
if (node === accessors.firstAccessor) {
2464+
emitJsDocComments(accessors.getAccessor);
2465+
emitJsDocComments(accessors.setAccessor);
24622466
emitDeclarationFlags(node);
24632467
emitSourceTextOfNode(node.name);
24642468
if (!(node.flags & NodeFlags.Private)) {

tests/baselines/reference/commentsClassMembers.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,15 +476,21 @@ declare class c1 {
476476
/** p1 is property of c1*/
477477
p1: number;
478478
p2(b: number): number;
479+
/** getter property*/
480+
/** setter property*/
479481
p3: number;
480482
/** pp1 is property of c1*/
481483
private pp1;
482484
private pp2(b);
485+
/** getter property*/
486+
/** setter property*/
483487
private pp3;
484488
constructor();
485489
/** s1 is static property of c1*/
486490
static s1: number;
487491
static s2(b: number): number;
492+
/** static getter property*/
493+
/** setter property*/
488494
static s3: number;
489495
nc_p1: number;
490496
nc_p2(b: number): number;
@@ -507,14 +513,22 @@ declare class c1 {
507513
/** p1 is property of c1 */
508514
b_p1: number;
509515
b_p2(b: number): number;
516+
/** getter property */
517+
/** setter property */
510518
b_p3: number;
511519
/** pp1 is property of c1 */
512520
private b_pp1;
513521
private b_pp2(b);
522+
/** getter property */
523+
/** setter property */
514524
private b_pp3;
515525
/** s1 is static property of c1 */
516526
static b_s1: number;
517527
static b_s2(b: number): number;
528+
/** static getter property
529+
*/
530+
/** setter property
531+
*/
518532
static b_s3: number;
519533
}
520534
declare var i1: c1;
@@ -537,8 +551,10 @@ declare var i1_s_ncprop: number;
537551
declare var i1_c: typeof c1;
538552
declare class cProperties {
539553
private val;
554+
/** getter only property*/
540555
p1: number;
541556
nc_p1: number;
557+
/**setter only property*/
542558
p2: number;
543559
nc_p2: number;
544560
}

tests/baselines/reference/commentsInheritance.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,13 +309,15 @@ declare class c2 {
309309
/** c2 c2_p1*/
310310
c2_p1: number;
311311
c2_f1(): void;
312+
/** c2 c2_prop*/
312313
c2_prop: number;
313314
c2_nc_p1: number;
314315
c2_nc_f1(): void;
315316
c2_nc_prop: number;
316317
/** c2 p1*/
317318
p1: number;
318319
f1(): void;
320+
/** c2 prop*/
319321
prop: number;
320322
nc_p1: number;
321323
nc_f1(): void;
@@ -327,6 +329,7 @@ declare class c3 extends c2 {
327329
/** c3 p1*/
328330
p1: number;
329331
f1(): void;
332+
/** c3 prop*/
330333
prop: number;
331334
nc_p1: number;
332335
nc_f1(): void;

tests/baselines/reference/commentsemitComments.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,8 @@ declare class c {
157157
/** property comment */
158158
b: number;
159159
myFoo(): number;
160+
/** getter comment*/
161+
/** setter comment*/
160162
prop1: number;
161163
foo1(a: number): string;
162164
foo1(b: string): string;

tests/baselines/reference/declFileAccessors.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,14 @@ var c2 = (function () {
271271
//// [declFileAccessors_0.d.ts]
272272
/** This is comment for c1*/
273273
export declare class c1 {
274+
/** getter property*/
275+
/** setter property*/
274276
p3: number;
277+
/** private getter property*/
278+
/** private setter property*/
275279
private pp3;
280+
/** static getter property*/
281+
/** setter property*/
276282
static s3: number;
277283
nc_p3: number;
278284
private nc_pp3;
@@ -283,8 +289,14 @@ export declare class c1 {
283289
//// [declFileAccessors_1.d.ts]
284290
/** This is comment for c2 - the global class*/
285291
declare class c2 {
292+
/** getter property*/
293+
/** setter property*/
286294
p3: number;
295+
/** private getter property*/
296+
/** private setter property*/
287297
private pp3;
298+
/** static getter property*/
299+
/** setter property*/
288300
static s3: number;
289301
nc_p3: number;
290302
private nc_pp3;

0 commit comments

Comments
 (0)