From b8bbb0d5475b1c8e1cb693f108b1817f1f729d9e Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Thu, 14 Aug 2014 09:35:58 -0700 Subject: [PATCH] Declaration comments for parameters in .d.ts file --- src/compiler/emitter.ts | 1 + .../reference/commentsClassMembers.js | 6 ++-- .../reference/commentsCommentParsing.js | 2 +- tests/baselines/reference/commentsFunction.js | 3 +- .../baselines/reference/commentsInterface.js | 10 +++---- tests/baselines/reference/commentsModules.js | 2 +- .../baselines/reference/commentsOverloads.js | 6 ++-- .../reference/commentsemitComments.js | 2 +- .../reference/declFileCallSignatures.js | 6 ++-- .../reference/declFileConstructSignatures.js | 6 ++-- .../reference/declFileConstructors.js | 6 ++-- .../baselines/reference/declFileFunctions.js | 6 ++-- tests/baselines/reference/declFileMethods.js | 30 ++++++++++++------- 13 files changed, 53 insertions(+), 33 deletions(-) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 690c5508ae7..34cf6de57f7 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -2647,6 +2647,7 @@ module ts { } function emitParameterDeclaration(node: ParameterDeclaration) { + emitJsDocComments(node); if (node.flags & NodeFlags.Rest) { write("..."); } diff --git a/tests/baselines/reference/commentsClassMembers.js b/tests/baselines/reference/commentsClassMembers.js index 70bfb460bfb..dd02e967b15 100644 --- a/tests/baselines/reference/commentsClassMembers.js +++ b/tests/baselines/reference/commentsClassMembers.js @@ -476,14 +476,14 @@ declare class c1 { /** p1 is property of c1*/ p1: number; /** sum with property*/ - p2(b: number): number; + p2(/** number to add*/ b: number): number; /** getter property*/ /** setter property*/ p3: number; /** pp1 is property of c1*/ private pp1; /** sum with property*/ - private pp2(b); + private pp2(/** number to add*/ b); /** getter property*/ /** setter property*/ private pp3; @@ -492,7 +492,7 @@ declare class c1 { /** s1 is static property of c1*/ static s1: number; /** static sum with property*/ - static s2(b: number): number; + static s2(/** number to add*/ b: number): number; /** static getter property*/ /** setter property*/ static s3: number; diff --git a/tests/baselines/reference/commentsCommentParsing.js b/tests/baselines/reference/commentsCommentParsing.js index 7822aacdda7..4fb9d802605 100644 --- a/tests/baselines/reference/commentsCommentParsing.js +++ b/tests/baselines/reference/commentsCommentParsing.js @@ -365,6 +365,6 @@ declare function divide(a: number, b: number): void; *@param a it is first parameter *@param c it is third parameter */ -declare function jsDocParamTest(a: number, b: number, c: number, d: number): number; +declare function jsDocParamTest(/** this is inline comment for a */ a: number, /** this is inline comment for b*/ b: number, c: number, d: number): number; declare class NoQuickInfoClass { } diff --git a/tests/baselines/reference/commentsFunction.js b/tests/baselines/reference/commentsFunction.js index b47bb9bbcc4..3913d59d7b0 100644 --- a/tests/baselines/reference/commentsFunction.js +++ b/tests/baselines/reference/commentsFunction.js @@ -52,7 +52,8 @@ lambddaNoVarComment(10, 20); /** This comment should appear for foo*/ declare function foo(): void; /** This is comment for function signature*/ -declare function fooWithParameters(a: string, b: number): void; +declare function fooWithParameters(/** this is comment about a*/ a: string, /** this is comment for b*/ +b: number): void; /** fooFunc * comment */ diff --git a/tests/baselines/reference/commentsInterface.js b/tests/baselines/reference/commentsInterface.js index f3f1f06785c..00255f74129 100644 --- a/tests/baselines/reference/commentsInterface.js +++ b/tests/baselines/reference/commentsInterface.js @@ -118,16 +118,16 @@ interface i2 { /** this is foo*/ foo: (b: number) => string; /** this is indexer*/ - [i: string]: any; + [/**string param*/ i: string]: any; /**new method*/ - new (i: i1): any; + new (/** param*/ i: i1): any; nc_x: number; nc_foo: (b: number) => string; [i: number]: number; /** this is call signature*/ - (a: number, b: number): number; + (/**paramhelp a*/ a: number, /**paramhelp b*/ b: number): number; /** this is fnfoo*/ - fnfoo(b: number): string; + fnfoo(/**param help*/ b: number): string; nc_fnfoo(b: number): string; nc_y: number; } @@ -150,7 +150,7 @@ interface i3 { /** Comment i3 x*/ x: number; /** Function i3 f*/ - f(a: number): string; + f(/**number parameter*/ a: number): string; /** i3 l*/ l: (b: number) => string; nc_x: number; diff --git a/tests/baselines/reference/commentsModules.js b/tests/baselines/reference/commentsModules.js index 63eebe1e4a4..c5fb8fbf115 100644 --- a/tests/baselines/reference/commentsModules.js +++ b/tests/baselines/reference/commentsModules.js @@ -285,7 +285,7 @@ declare module m1 { } /** exported function*/ function fooExport(): number; - function foo2Export(a: string): void; + function foo2Export(/**hm*/ a: string): void; /** foo3Export * comment */ diff --git a/tests/baselines/reference/commentsOverloads.js b/tests/baselines/reference/commentsOverloads.js index 518e268d1e9..d55993572c0 100644 --- a/tests/baselines/reference/commentsOverloads.js +++ b/tests/baselines/reference/commentsOverloads.js @@ -262,7 +262,7 @@ var c5_i_2 = new c5("hello"); //// [commentsOverloads.d.ts] /** this is signature 1*/ -declare function f1(a: number): number; +declare function f1(/**param a*/ a: number): number; declare function f1(b: string): number; declare function f2(a: number): number; /** this is signature 2*/ @@ -270,12 +270,12 @@ declare function f2(b: string): number; declare function f3(a: number): number; declare function f3(b: string): number; /** this is signature 4 - with number parameter*/ -declare function f4(a: number): number; +declare function f4(/**param a*/ a: number): number; /** this is signature 4 - with string parameter*/ declare function f4(b: string): number; interface i1 { /**this signature 1*/ - (a: number): number; + (/**param a*/ a: number): number; /**this is signature 2*/ (b: string): number; /** foo 1*/ diff --git a/tests/baselines/reference/commentsemitComments.js b/tests/baselines/reference/commentsemitComments.js index 745e64a4f1a..fdb6b45d704 100644 --- a/tests/baselines/reference/commentsemitComments.js +++ b/tests/baselines/reference/commentsemitComments.js @@ -149,7 +149,7 @@ var m1; /** Variable comments*/ declare var myVariable: number; /** function comments*/ -declare function foo(p: number): void; +declare function foo(/** parameter comment*/ p: number): void; /** variable with function type comment*/ declare var fooVar: () => void; /**class comment*/ diff --git a/tests/baselines/reference/declFileCallSignatures.js b/tests/baselines/reference/declFileCallSignatures.js index 3fe5f52bc9e..cf09607a644 100644 --- a/tests/baselines/reference/declFileCallSignatures.js +++ b/tests/baselines/reference/declFileCallSignatures.js @@ -76,7 +76,8 @@ export interface ICallSignature { } export interface ICallSignatureWithParameters { /** This is comment for function signature*/ - (a: string, b: number): void; + (/** this is comment about a*/ a: string, /** this is comment for b*/ + b: number): void; } export interface ICallSignatureWithRestParameters { (a: string, ...rests: string[]): string; @@ -99,7 +100,8 @@ interface IGlobalCallSignature { } interface IGlobalCallSignatureWithParameters { /** This is comment for function signature*/ - (a: string, b: number): void; + (/** this is comment about a*/ a: string, /** this is comment for b*/ + b: number): void; } interface IGlobalCallSignatureWithRestParameters { (a: string, ...rests: string[]): string; diff --git a/tests/baselines/reference/declFileConstructSignatures.js b/tests/baselines/reference/declFileConstructSignatures.js index aaf9e45c6e2..48fb9208e9e 100644 --- a/tests/baselines/reference/declFileConstructSignatures.js +++ b/tests/baselines/reference/declFileConstructSignatures.js @@ -76,7 +76,8 @@ export interface IConstructSignature { } export interface IConstructSignatureWithParameters { /** This is comment for function signature*/ - new (a: string, b: number): any; + new (/** this is comment about a*/ a: string, /** this is comment for b*/ + b: number): any; } export interface IConstructSignatureWithRestParameters { new (a: string, ...rests: string[]): string; @@ -99,7 +100,8 @@ interface IGlobalConstructSignature { } interface IGlobalConstructSignatureWithParameters { /** This is comment for function signature*/ - new (a: string, b: number): any; + new (/** this is comment about a*/ a: string, /** this is comment for b*/ + b: number): any; } interface IGlobalConstructSignatureWithRestParameters { new (a: string, ...rests: string[]): string; diff --git a/tests/baselines/reference/declFileConstructors.js b/tests/baselines/reference/declFileConstructors.js index 6bc0818001e..060b9bf55da 100644 --- a/tests/baselines/reference/declFileConstructors.js +++ b/tests/baselines/reference/declFileConstructors.js @@ -224,7 +224,8 @@ export declare class SimpleConstructor { } export declare class ConstructorWithParameters { /** This is comment for function signature*/ - constructor(a: string, b: number); + constructor(/** this is comment about a*/ a: string, /** this is comment for b*/ + b: number); } export declare class ConstructorWithRestParamters { constructor(a: string, ...rests: string[]); @@ -256,7 +257,8 @@ declare class GlobalSimpleConstructor { } declare class GlobalConstructorWithParameters { /** This is comment for function signature*/ - constructor(a: string, b: number); + constructor(/** this is comment about a*/ a: string, /** this is comment for b*/ + b: number); } declare class GlobalConstructorWithRestParamters { constructor(a: string, ...rests: string[]); diff --git a/tests/baselines/reference/declFileFunctions.js b/tests/baselines/reference/declFileFunctions.js index 5e15a8f7cc7..2f1b64a6695 100644 --- a/tests/baselines/reference/declFileFunctions.js +++ b/tests/baselines/reference/declFileFunctions.js @@ -125,7 +125,8 @@ function globalfooWithOverloads(a) { /** This comment should appear for foo*/ export declare function foo(): void; /** This is comment for function signature*/ -export declare function fooWithParameters(a: string, b: number): void; +export declare function fooWithParameters(/** this is comment about a*/ a: string, /** this is comment for b*/ +b: number): void; export declare function fooWithRestParameters(a: string, ...rests: string[]): string; export declare function fooWithOverloads(a: string): string; export declare function fooWithOverloads(a: number): number; @@ -133,7 +134,8 @@ export declare function fooWithOverloads(a: number): number; /** This comment should appear for foo*/ declare function globalfoo(): void; /** This is comment for function signature*/ -declare function globalfooWithParameters(a: string, b: number): void; +declare function globalfooWithParameters(/** this is comment about a*/ a: string, /** this is comment for b*/ +b: number): void; declare function globalfooWithRestParameters(a: string, ...rests: string[]): string; declare function globalfooWithOverloads(a: string): string; declare function globalfooWithOverloads(a: number): number; diff --git a/tests/baselines/reference/declFileMethods.js b/tests/baselines/reference/declFileMethods.js index f7c14ae885f..0336e60b6b6 100644 --- a/tests/baselines/reference/declFileMethods.js +++ b/tests/baselines/reference/declFileMethods.js @@ -354,28 +354,32 @@ export declare class c1 { /** This comment should appear for foo*/ foo(): void; /** This is comment for function signature*/ - fooWithParameters(a: string, b: number): void; + fooWithParameters(/** this is comment about a*/ a: string, /** this is comment for b*/ + b: number): void; fooWithRestParameters(a: string, ...rests: string[]): string; fooWithOverloads(a: string): string; fooWithOverloads(a: number): number; /** This comment should appear for privateFoo*/ private privateFoo(); /** This is comment for function signature*/ - private privateFooWithParameters(a, b); + private privateFooWithParameters(/** this is comment about a*/ a, /** this is comment for b*/ + b); private privateFooWithRestParameters(a, ...rests); private privateFooWithOverloads(a); private privateFooWithOverloads(a); /** This comment should appear for static foo*/ static staticFoo(): void; /** This is comment for function signature*/ - static staticFooWithParameters(a: string, b: number): void; + static staticFooWithParameters(/** this is comment about a*/ a: string, /** this is comment for b*/ + b: number): void; static staticFooWithRestParameters(a: string, ...rests: string[]): string; static staticFooWithOverloads(a: string): string; static staticFooWithOverloads(a: number): number; /** This comment should appear for privateStaticFoo*/ private static privateStaticFoo(); /** This is comment for function signature*/ - private static privateStaticFooWithParameters(a, b); + private static privateStaticFooWithParameters(/** this is comment about a*/ a, /** this is comment for b*/ + b); private static privateStaticFooWithRestParameters(a, ...rests); private static privateStaticFooWithOverloads(a); private static privateStaticFooWithOverloads(a); @@ -384,7 +388,8 @@ export interface I1 { /** This comment should appear for foo*/ foo(): string; /** This is comment for function signature*/ - fooWithParameters(a: string, b: number): void; + fooWithParameters(/** this is comment about a*/ a: string, /** this is comment for b*/ + b: number): void; fooWithRestParameters(a: string, ...rests: string[]): string; fooWithOverloads(a: string): string; fooWithOverloads(a: number): number; @@ -394,28 +399,32 @@ declare class c2 { /** This comment should appear for foo*/ foo(): void; /** This is comment for function signature*/ - fooWithParameters(a: string, b: number): void; + fooWithParameters(/** this is comment about a*/ a: string, /** this is comment for b*/ + b: number): void; fooWithRestParameters(a: string, ...rests: string[]): string; fooWithOverloads(a: string): string; fooWithOverloads(a: number): number; /** This comment should appear for privateFoo*/ private privateFoo(); /** This is comment for function signature*/ - private privateFooWithParameters(a, b); + private privateFooWithParameters(/** this is comment about a*/ a, /** this is comment for b*/ + b); private privateFooWithRestParameters(a, ...rests); private privateFooWithOverloads(a); private privateFooWithOverloads(a); /** This comment should appear for static foo*/ static staticFoo(): void; /** This is comment for function signature*/ - static staticFooWithParameters(a: string, b: number): void; + static staticFooWithParameters(/** this is comment about a*/ a: string, /** this is comment for b*/ + b: number): void; static staticFooWithRestParameters(a: string, ...rests: string[]): string; static staticFooWithOverloads(a: string): string; static staticFooWithOverloads(a: number): number; /** This comment should appear for privateStaticFoo*/ private static privateStaticFoo(); /** This is comment for function signature*/ - private static privateStaticFooWithParameters(a, b); + private static privateStaticFooWithParameters(/** this is comment about a*/ a, /** this is comment for b*/ + b); private static privateStaticFooWithRestParameters(a, ...rests); private static privateStaticFooWithOverloads(a); private static privateStaticFooWithOverloads(a); @@ -424,7 +433,8 @@ interface I2 { /** This comment should appear for foo*/ foo(): string; /** This is comment for function signature*/ - fooWithParameters(a: string, b: number): void; + fooWithParameters(/** this is comment about a*/ a: string, /** this is comment for b*/ + b: number): void; fooWithRestParameters(a: string, ...rests: string[]): string; fooWithOverloads(a: string): string; fooWithOverloads(a: number): number;