Skip to content

Commit b8bbb0d

Browse files
committed
Declaration comments for parameters in .d.ts file
1 parent 6bf73a6 commit b8bbb0d

13 files changed

+53
-33
lines changed

src/compiler/emitter.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2647,6 +2647,7 @@ module ts {
26472647
}
26482648

26492649
function emitParameterDeclaration(node: ParameterDeclaration) {
2650+
emitJsDocComments(node);
26502651
if (node.flags & NodeFlags.Rest) {
26512652
write("...");
26522653
}

tests/baselines/reference/commentsClassMembers.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -476,14 +476,14 @@ declare class c1 {
476476
/** p1 is property of c1*/
477477
p1: number;
478478
/** sum with property*/
479-
p2(b: number): number;
479+
p2(/** number to add*/ b: number): number;
480480
/** getter property*/
481481
/** setter property*/
482482
p3: number;
483483
/** pp1 is property of c1*/
484484
private pp1;
485485
/** sum with property*/
486-
private pp2(b);
486+
private pp2(/** number to add*/ b);
487487
/** getter property*/
488488
/** setter property*/
489489
private pp3;
@@ -492,7 +492,7 @@ declare class c1 {
492492
/** s1 is static property of c1*/
493493
static s1: number;
494494
/** static sum with property*/
495-
static s2(b: number): number;
495+
static s2(/** number to add*/ b: number): number;
496496
/** static getter property*/
497497
/** setter property*/
498498
static s3: number;

tests/baselines/reference/commentsCommentParsing.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,6 @@ declare function divide(a: number, b: number): void;
365365
*@param a it is first parameter
366366
*@param c it is third parameter
367367
*/
368-
declare function jsDocParamTest(a: number, b: number, c: number, d: number): number;
368+
declare function jsDocParamTest(/** this is inline comment for a */ a: number, /** this is inline comment for b*/ b: number, c: number, d: number): number;
369369
declare class NoQuickInfoClass {
370370
}

tests/baselines/reference/commentsFunction.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ lambddaNoVarComment(10, 20);
5252
/** This comment should appear for foo*/
5353
declare function foo(): void;
5454
/** This is comment for function signature*/
55-
declare function fooWithParameters(a: string, b: number): void;
55+
declare function fooWithParameters(/** this is comment about a*/ a: string, /** this is comment for b*/
56+
b: number): void;
5657
/** fooFunc
5758
* comment
5859
*/

tests/baselines/reference/commentsInterface.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,16 +118,16 @@ interface i2 {
118118
/** this is foo*/
119119
foo: (b: number) => string;
120120
/** this is indexer*/
121-
[i: string]: any;
121+
[/**string param*/ i: string]: any;
122122
/**new method*/
123-
new (i: i1): any;
123+
new (/** param*/ i: i1): any;
124124
nc_x: number;
125125
nc_foo: (b: number) => string;
126126
[i: number]: number;
127127
/** this is call signature*/
128-
(a: number, b: number): number;
128+
(/**paramhelp a*/ a: number, /**paramhelp b*/ b: number): number;
129129
/** this is fnfoo*/
130-
fnfoo(b: number): string;
130+
fnfoo(/**param help*/ b: number): string;
131131
nc_fnfoo(b: number): string;
132132
nc_y: number;
133133
}
@@ -150,7 +150,7 @@ interface i3 {
150150
/** Comment i3 x*/
151151
x: number;
152152
/** Function i3 f*/
153-
f(a: number): string;
153+
f(/**number parameter*/ a: number): string;
154154
/** i3 l*/
155155
l: (b: number) => string;
156156
nc_x: number;

tests/baselines/reference/commentsModules.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ declare module m1 {
285285
}
286286
/** exported function*/
287287
function fooExport(): number;
288-
function foo2Export(a: string): void;
288+
function foo2Export(/**hm*/ a: string): void;
289289
/** foo3Export
290290
* comment
291291
*/

tests/baselines/reference/commentsOverloads.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -262,20 +262,20 @@ var c5_i_2 = new c5("hello");
262262

263263
//// [commentsOverloads.d.ts]
264264
/** this is signature 1*/
265-
declare function f1(a: number): number;
265+
declare function f1(/**param a*/ a: number): number;
266266
declare function f1(b: string): number;
267267
declare function f2(a: number): number;
268268
/** this is signature 2*/
269269
declare function f2(b: string): number;
270270
declare function f3(a: number): number;
271271
declare function f3(b: string): number;
272272
/** this is signature 4 - with number parameter*/
273-
declare function f4(a: number): number;
273+
declare function f4(/**param a*/ a: number): number;
274274
/** this is signature 4 - with string parameter*/
275275
declare function f4(b: string): number;
276276
interface i1 {
277277
/**this signature 1*/
278-
(a: number): number;
278+
(/**param a*/ a: number): number;
279279
/**this is signature 2*/
280280
(b: string): number;
281281
/** foo 1*/

tests/baselines/reference/commentsemitComments.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ var m1;
149149
/** Variable comments*/
150150
declare var myVariable: number;
151151
/** function comments*/
152-
declare function foo(p: number): void;
152+
declare function foo(/** parameter comment*/ p: number): void;
153153
/** variable with function type comment*/
154154
declare var fooVar: () => void;
155155
/**class comment*/

tests/baselines/reference/declFileCallSignatures.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ export interface ICallSignature {
7676
}
7777
export interface ICallSignatureWithParameters {
7878
/** This is comment for function signature*/
79-
(a: string, b: number): void;
79+
(/** this is comment about a*/ a: string, /** this is comment for b*/
80+
b: number): void;
8081
}
8182
export interface ICallSignatureWithRestParameters {
8283
(a: string, ...rests: string[]): string;
@@ -99,7 +100,8 @@ interface IGlobalCallSignature {
99100
}
100101
interface IGlobalCallSignatureWithParameters {
101102
/** This is comment for function signature*/
102-
(a: string, b: number): void;
103+
(/** this is comment about a*/ a: string, /** this is comment for b*/
104+
b: number): void;
103105
}
104106
interface IGlobalCallSignatureWithRestParameters {
105107
(a: string, ...rests: string[]): string;

tests/baselines/reference/declFileConstructSignatures.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ export interface IConstructSignature {
7676
}
7777
export interface IConstructSignatureWithParameters {
7878
/** This is comment for function signature*/
79-
new (a: string, b: number): any;
79+
new (/** this is comment about a*/ a: string, /** this is comment for b*/
80+
b: number): any;
8081
}
8182
export interface IConstructSignatureWithRestParameters {
8283
new (a: string, ...rests: string[]): string;
@@ -99,7 +100,8 @@ interface IGlobalConstructSignature {
99100
}
100101
interface IGlobalConstructSignatureWithParameters {
101102
/** This is comment for function signature*/
102-
new (a: string, b: number): any;
103+
new (/** this is comment about a*/ a: string, /** this is comment for b*/
104+
b: number): any;
103105
}
104106
interface IGlobalConstructSignatureWithRestParameters {
105107
new (a: string, ...rests: string[]): string;

0 commit comments

Comments
 (0)