mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-10 17:05:58 -05:00
Declaration comments for function declarations in .d.ts
This commit is contained in:
@@ -2523,6 +2523,7 @@ module ts {
|
||||
// so no need to verify if the declaration is visible
|
||||
if ((node.kind !== SyntaxKind.FunctionDeclaration || resolver.isDeclarationVisible(node)) &&
|
||||
!resolver.isImplementationOfOverload(node)) {
|
||||
emitJsDocComments(node);
|
||||
emitDeclarationFlags(node);
|
||||
if (node.kind === SyntaxKind.FunctionDeclaration) {
|
||||
write("function ");
|
||||
|
||||
@@ -137,12 +137,14 @@ declare class c2 {
|
||||
declare var i2: c2;
|
||||
declare var i2_c: typeof c2;
|
||||
declare class c3 {
|
||||
/** Constructor comment*/
|
||||
constructor();
|
||||
}
|
||||
declare var i3: c3;
|
||||
declare var i3_c: typeof c3;
|
||||
/** Class comment*/
|
||||
declare class c4 {
|
||||
/** Constructor comment*/
|
||||
constructor();
|
||||
}
|
||||
declare var i4: c4;
|
||||
@@ -170,6 +172,8 @@ declare var i7_c: typeof c7;
|
||||
declare class c8 {
|
||||
/** s1 comment */
|
||||
static s1: number;
|
||||
/** constructor comment
|
||||
*/
|
||||
constructor();
|
||||
}
|
||||
declare var i8: c8;
|
||||
|
||||
@@ -475,19 +475,23 @@ cProperties_i.nc_p2 = cProperties_i.nc_p1;
|
||||
declare class c1 {
|
||||
/** p1 is property of c1*/
|
||||
p1: number;
|
||||
/** sum with property*/
|
||||
p2(b: number): number;
|
||||
/** getter property*/
|
||||
/** setter property*/
|
||||
p3: number;
|
||||
/** pp1 is property of c1*/
|
||||
private pp1;
|
||||
/** sum with property*/
|
||||
private pp2(b);
|
||||
/** getter property*/
|
||||
/** setter property*/
|
||||
private pp3;
|
||||
/** Constructor method*/
|
||||
constructor();
|
||||
/** s1 is static property of c1*/
|
||||
static s1: number;
|
||||
/** static sum with property*/
|
||||
static s2(b: number): number;
|
||||
/** static getter property*/
|
||||
/** setter property*/
|
||||
@@ -512,18 +516,21 @@ declare class c1 {
|
||||
static a_s3: number;
|
||||
/** p1 is property of c1 */
|
||||
b_p1: number;
|
||||
/** sum with property */
|
||||
b_p2(b: number): number;
|
||||
/** getter property */
|
||||
/** setter property */
|
||||
b_p3: number;
|
||||
/** pp1 is property of c1 */
|
||||
private b_pp1;
|
||||
/** sum with property */
|
||||
private b_pp2(b);
|
||||
/** getter property */
|
||||
/** setter property */
|
||||
private b_pp3;
|
||||
/** s1 is static property of c1 */
|
||||
static b_s1: number;
|
||||
/** static sum with property */
|
||||
static b_s2(b: number): number;
|
||||
/** static getter property
|
||||
*/
|
||||
|
||||
@@ -294,25 +294,77 @@ var NoQuickInfoClass = (function () {
|
||||
//// [commentsCommentParsing.d.ts]
|
||||
declare function simple(): void;
|
||||
declare function multiLine(): void;
|
||||
/** this is eg of single line jsdoc style comment */
|
||||
declare function jsDocSingleLine(): void;
|
||||
/** this is multiple line jsdoc stule comment
|
||||
*New line1
|
||||
*New Line2*/
|
||||
declare function jsDocMultiLine(): void;
|
||||
/** this is multiple line jsdoc stule comment
|
||||
*New line1
|
||||
*New Line2*/
|
||||
/** Shoul mege this line as well
|
||||
* and this too*/ /** Another this one too*/
|
||||
declare function jsDocMultiLineMerge(): void;
|
||||
/** jsdoc comment */
|
||||
declare function jsDocMixedComments1(): void;
|
||||
/** jsdoc comment */ /*** another jsDocComment*/
|
||||
declare function jsDocMixedComments2(): void;
|
||||
/** jsdoc comment */ /*** another jsDocComment*/
|
||||
declare function jsDocMixedComments3(): void;
|
||||
/** jsdoc comment */ /*** another jsDocComment*/
|
||||
declare function jsDocMixedComments4(): void;
|
||||
/** jsdoc comment */ /*** another jsDocComment*/
|
||||
declare function jsDocMixedComments5(): void;
|
||||
/*** another jsDocComment*/
|
||||
/** jsdoc comment */
|
||||
declare function jsDocMixedComments6(): void;
|
||||
declare function noHelpComment1(): void;
|
||||
declare function noHelpComment2(): void;
|
||||
declare function noHelpComment3(): void;
|
||||
/** Adds two integers and returns the result
|
||||
* @param {number} a first number
|
||||
* @param b second number
|
||||
*/
|
||||
declare function sum(a: number, b: number): number;
|
||||
/** This is multiplication function*/
|
||||
/** @param */
|
||||
/** @param a first number*/
|
||||
/** @param b */
|
||||
/** @param c {
|
||||
@param d @anotherTag*/
|
||||
/** @param e LastParam @anotherTag*/
|
||||
declare function multiply(a: number, b: number, c?: number, d?: any, e?: any): void;
|
||||
/** fn f1 with number
|
||||
* @param { string} b about b
|
||||
*/
|
||||
declare function f1(a: number): any;
|
||||
declare function f1(b: string): any;
|
||||
/** This is subtract function
|
||||
@param { a
|
||||
*@param { number | } b this is about b
|
||||
@param { { () => string; } } c this is optional param c
|
||||
@param { { () => string; } d this is optional param d
|
||||
@param { { () => string; } } e this is optional param e
|
||||
@param { { { () => string; } } f this is optional param f
|
||||
*/
|
||||
declare function subtract(a: number, b: number, c?: () => string, d?: () => string, e?: () => string, f?: () => string): void;
|
||||
/** this is square function
|
||||
@paramTag { number } a this is input number of paramTag
|
||||
@param { number } a this is input number
|
||||
@returnType { number } it is return type
|
||||
*/
|
||||
declare function square(a: number): number;
|
||||
/** this is divide function
|
||||
@param { number} a this is a
|
||||
@paramTag { number } g this is optional param g
|
||||
@param { number} b this is b
|
||||
*/
|
||||
declare function divide(a: number, b: number): void;
|
||||
/** this is jsdoc style function with param tag as well as inline parameter help
|
||||
*@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 class NoQuickInfoClass {
|
||||
}
|
||||
|
||||
@@ -150,6 +150,7 @@ export declare module m1 {
|
||||
/** i*/
|
||||
var i: c;
|
||||
}
|
||||
/** exported function*/
|
||||
function fooExport(): number;
|
||||
}
|
||||
/** Module comment */
|
||||
@@ -165,6 +166,7 @@ export declare module m4 {
|
||||
/** i */
|
||||
var i: c;
|
||||
}
|
||||
/** exported function */
|
||||
function fooExport(): number;
|
||||
}
|
||||
//// [commentsExternalModules_1.d.ts]
|
||||
|
||||
@@ -150,6 +150,7 @@ export declare module m1 {
|
||||
/** i*/
|
||||
var i: c;
|
||||
}
|
||||
/** exported function*/
|
||||
function fooExport(): number;
|
||||
}
|
||||
/** Module comment */
|
||||
@@ -165,6 +166,7 @@ export declare module m4 {
|
||||
/** i */
|
||||
var i: c;
|
||||
}
|
||||
/** exported function */
|
||||
function fooExport(): number;
|
||||
}
|
||||
//// [commentsExternalModules_1.d.ts]
|
||||
|
||||
@@ -49,7 +49,9 @@ lambddaNoVarComment(10, 20);
|
||||
|
||||
|
||||
//// [commentsFunction.d.ts]
|
||||
/** This comment should appear for foo*/
|
||||
declare function foo(): void;
|
||||
/** This is comment for function signature*/
|
||||
declare function fooWithParameters(a: string, b: number): void;
|
||||
/** fooFunc
|
||||
* comment
|
||||
|
||||
@@ -272,6 +272,7 @@ i2_i = i3_i;
|
||||
interface i1 {
|
||||
/** i1_p1*/
|
||||
i1_p1: number;
|
||||
/** i1_f1*/
|
||||
i1_f1(): void;
|
||||
/** i1_l1*/
|
||||
i1_l1: () => void;
|
||||
@@ -294,11 +295,13 @@ declare class c1 implements i1 {
|
||||
i1_nc_l1: () => void;
|
||||
/** c1_p1*/
|
||||
p1: number;
|
||||
/** c1_f1*/
|
||||
f1(): void;
|
||||
/** c1_l1*/
|
||||
l1: () => void;
|
||||
/** c1_nc_p1*/
|
||||
nc_p1: number;
|
||||
/** c1_nc_f1*/
|
||||
nc_f1(): void;
|
||||
/** c1_nc_l1*/
|
||||
nc_l1: () => void;
|
||||
@@ -308,6 +311,7 @@ declare var c1_i: c1;
|
||||
declare class c2 {
|
||||
/** c2 c2_p1*/
|
||||
c2_p1: number;
|
||||
/** c2 c2_f1*/
|
||||
c2_f1(): void;
|
||||
/** c2 c2_prop*/
|
||||
c2_prop: number;
|
||||
@@ -316,18 +320,21 @@ declare class c2 {
|
||||
c2_nc_prop: number;
|
||||
/** c2 p1*/
|
||||
p1: number;
|
||||
/** c2 f1*/
|
||||
f1(): void;
|
||||
/** c2 prop*/
|
||||
prop: number;
|
||||
nc_p1: number;
|
||||
nc_f1(): void;
|
||||
nc_prop: number;
|
||||
/** c2 constructor*/
|
||||
constructor(a: number);
|
||||
}
|
||||
declare class c3 extends c2 {
|
||||
constructor();
|
||||
/** c3 p1*/
|
||||
p1: number;
|
||||
/** c3 f1*/
|
||||
f1(): void;
|
||||
/** c3 prop*/
|
||||
prop: number;
|
||||
@@ -343,6 +350,7 @@ declare var c4_i: c4;
|
||||
interface i2 {
|
||||
/** i2_p1*/
|
||||
i2_p1: number;
|
||||
/** i2_f1*/
|
||||
i2_f1(): void;
|
||||
/** i2_l1*/
|
||||
i2_l1: () => void;
|
||||
@@ -351,6 +359,7 @@ interface i2 {
|
||||
i2_nc_l1: () => void;
|
||||
/** i2 p1*/
|
||||
p1: number;
|
||||
/** i2 f1*/
|
||||
f1(): void;
|
||||
/** i2 l1*/
|
||||
l1: () => void;
|
||||
@@ -361,6 +370,9 @@ interface i2 {
|
||||
interface i3 extends i2 {
|
||||
/** i3 p1 */
|
||||
p1: number;
|
||||
/**
|
||||
* i3 f1
|
||||
*/
|
||||
f1(): void;
|
||||
/** i3 l1*/
|
||||
l1: () => void;
|
||||
|
||||
@@ -123,6 +123,7 @@ interface i2 {
|
||||
nc_foo: (b: number) => string;
|
||||
[i: number]: number;
|
||||
(a: number, b: number): number;
|
||||
/** this is fnfoo*/
|
||||
fnfoo(b: number): string;
|
||||
nc_fnfoo(b: number): string;
|
||||
nc_y: number;
|
||||
@@ -145,6 +146,7 @@ declare var i2_i_nc_fnfoo_r: string;
|
||||
interface i3 {
|
||||
/** Comment i3 x*/
|
||||
x: number;
|
||||
/** Function i3 f*/
|
||||
f(a: number): string;
|
||||
/** i3 l*/
|
||||
l: (b: number) => string;
|
||||
|
||||
@@ -283,8 +283,12 @@ declare module m1 {
|
||||
/** i*/
|
||||
var i: c;
|
||||
}
|
||||
/** exported function*/
|
||||
function fooExport(): number;
|
||||
function foo2Export(a: string): void;
|
||||
/** foo3Export
|
||||
* comment
|
||||
*/
|
||||
function foo3Export(): void;
|
||||
}
|
||||
declare var myvar: m1.m2.c;
|
||||
|
||||
@@ -261,27 +261,37 @@ var c5_i_2 = new c5("hello");
|
||||
|
||||
|
||||
//// [commentsOverloads.d.ts]
|
||||
/** this is signature 1*/
|
||||
declare function f1(a: number): number;
|
||||
declare function f1(b: string): number;
|
||||
declare function f2(a: number): number;
|
||||
/** this is signature 2*/
|
||||
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;
|
||||
/** this is signature 4 - with string parameter*/
|
||||
declare function f4(b: string): number;
|
||||
interface i1 {
|
||||
(a: number): number;
|
||||
(b: string): number;
|
||||
/** foo 1*/
|
||||
foo(a: number): number;
|
||||
/** foo 2*/
|
||||
foo(b: string): number;
|
||||
foo(arr: number[]): number;
|
||||
/** foo 4 */
|
||||
foo(arr: string[]): number;
|
||||
foo2(a: number): number;
|
||||
/** foo2 2*/
|
||||
foo2(b: string): number;
|
||||
foo3(a: number): number;
|
||||
foo3(b: string): number;
|
||||
/** foo4 1*/
|
||||
foo4(a: number): number;
|
||||
foo4(b: string): number;
|
||||
/** foo4 any */
|
||||
foo4(c: any): any;
|
||||
new (a: string): any;
|
||||
new (b: number): any;
|
||||
@@ -310,13 +320,19 @@ interface i4 {
|
||||
declare class c {
|
||||
prop1(a: number): number;
|
||||
prop1(b: string): number;
|
||||
/** prop2 1*/
|
||||
prop2(a: number): number;
|
||||
prop2(b: string): number;
|
||||
prop3(a: number): number;
|
||||
/** prop3 2*/
|
||||
prop3(b: string): number;
|
||||
/** prop4 1*/
|
||||
prop4(a: number): number;
|
||||
/** prop4 2*/
|
||||
prop4(b: string): number;
|
||||
/** prop5 1*/
|
||||
prop5(a: number): number;
|
||||
/** prop5 2*/
|
||||
prop5(b: string): number;
|
||||
}
|
||||
declare class c1 {
|
||||
@@ -324,19 +340,25 @@ declare class c1 {
|
||||
constructor(b: string);
|
||||
}
|
||||
declare class c2 {
|
||||
/** c2 1*/
|
||||
constructor(a: number);
|
||||
constructor(b: string);
|
||||
}
|
||||
declare class c3 {
|
||||
constructor(a: number);
|
||||
/** c3 2*/
|
||||
constructor(b: string);
|
||||
}
|
||||
declare class c4 {
|
||||
/** c4 1*/
|
||||
constructor(a: number);
|
||||
/** c4 2*/
|
||||
constructor(b: string);
|
||||
}
|
||||
declare class c5 {
|
||||
/** c5 1*/
|
||||
constructor(a: number);
|
||||
/** c5 2*/
|
||||
constructor(b: string);
|
||||
}
|
||||
declare var c_i: c;
|
||||
|
||||
@@ -148,19 +148,24 @@ var m1;
|
||||
//// [commentsemitComments.d.ts]
|
||||
/** Variable comments*/
|
||||
declare var myVariable: number;
|
||||
/** function comments*/
|
||||
declare function foo(p: number): void;
|
||||
/** variable with function type comment*/
|
||||
declare var fooVar: () => void;
|
||||
/**class comment*/
|
||||
declare class c {
|
||||
/** constructor comment*/
|
||||
constructor();
|
||||
/** property comment */
|
||||
b: number;
|
||||
/** function comment */
|
||||
myFoo(): number;
|
||||
/** getter comment*/
|
||||
/** setter comment*/
|
||||
prop1: number;
|
||||
/** overload signature1*/
|
||||
foo1(a: number): string;
|
||||
/** Overload signature 2*/
|
||||
foo1(b: string): string;
|
||||
}
|
||||
/**instance comment*/
|
||||
@@ -170,6 +175,7 @@ interface i1 {
|
||||
(a: number): number;
|
||||
new (b: string): any;
|
||||
[a: number]: string;
|
||||
/** function property;*/
|
||||
myFoo(a: number): string;
|
||||
/** prop*/
|
||||
prop: string;
|
||||
|
||||
@@ -219,9 +219,11 @@ var GlobalConstructorWithParameterInitializer = (function () {
|
||||
|
||||
//// [declFileConstructors_0.d.ts]
|
||||
export declare class SimpleConstructor {
|
||||
/** This comment should appear for foo*/
|
||||
constructor();
|
||||
}
|
||||
export declare class ConstructorWithParameters {
|
||||
/** This is comment for function signature*/
|
||||
constructor(a: string, b: number);
|
||||
}
|
||||
export declare class ConstructorWithRestParamters {
|
||||
@@ -249,9 +251,11 @@ export declare class ConstructorWithParameterInitializer {
|
||||
}
|
||||
//// [declFileConstructors_1.d.ts]
|
||||
declare class GlobalSimpleConstructor {
|
||||
/** This comment should appear for foo*/
|
||||
constructor();
|
||||
}
|
||||
declare class GlobalConstructorWithParameters {
|
||||
/** This is comment for function signature*/
|
||||
constructor(a: string, b: number);
|
||||
}
|
||||
declare class GlobalConstructorWithRestParamters {
|
||||
|
||||
@@ -122,13 +122,17 @@ function globalfooWithOverloads(a) {
|
||||
|
||||
|
||||
//// [declFileFunctions_0.d.ts]
|
||||
/** 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 fooWithRestParameters(a: string, ...rests: string[]): string;
|
||||
export declare function fooWithOverloads(a: string): string;
|
||||
export declare function fooWithOverloads(a: number): number;
|
||||
//// [declFileFunctions_1.d.ts]
|
||||
/** 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 globalfooWithRestParameters(a: string, ...rests: string[]): string;
|
||||
declare function globalfooWithOverloads(a: string): string;
|
||||
|
||||
@@ -351,29 +351,39 @@ var c2 = (function () {
|
||||
|
||||
//// [declFileMethods_0.d.ts]
|
||||
export declare class c1 {
|
||||
/** This comment should appear for foo*/
|
||||
foo(): void;
|
||||
/** This is comment for function signature*/
|
||||
fooWithParameters(a: string, 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 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 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 privateStaticFooWithRestParameters(a, ...rests);
|
||||
private static privateStaticFooWithOverloads(a);
|
||||
private static privateStaticFooWithOverloads(a);
|
||||
}
|
||||
export interface I1 {
|
||||
/** This comment should appear for foo*/
|
||||
foo(): string;
|
||||
/** This is comment for function signature*/
|
||||
fooWithParameters(a: string, b: number): void;
|
||||
fooWithRestParameters(a: string, ...rests: string[]): string;
|
||||
fooWithOverloads(a: string): string;
|
||||
@@ -381,29 +391,39 @@ export interface I1 {
|
||||
}
|
||||
//// [declFileMethods_1.d.ts]
|
||||
declare class c2 {
|
||||
/** This comment should appear for foo*/
|
||||
foo(): void;
|
||||
/** This is comment for function signature*/
|
||||
fooWithParameters(a: string, 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 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 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 privateStaticFooWithRestParameters(a, ...rests);
|
||||
private static privateStaticFooWithOverloads(a);
|
||||
private static privateStaticFooWithOverloads(a);
|
||||
}
|
||||
interface I2 {
|
||||
/** This comment should appear for foo*/
|
||||
foo(): string;
|
||||
/** This is comment for function signature*/
|
||||
fooWithParameters(a: string, b: number): void;
|
||||
fooWithRestParameters(a: string, ...rests: string[]): string;
|
||||
fooWithOverloads(a: string): string;
|
||||
|
||||
Reference in New Issue
Block a user