Declaration comments for call, constructo and index signatures in .d.ts

This commit is contained in:
Sheetal Nandi 2014-08-14 09:12:20 -07:00
parent d970c89856
commit 6bf73a691a
6 changed files with 31 additions and 0 deletions

View File

@ -2543,11 +2543,16 @@ module ts {
}
function emitConstructSignatureDeclaration(node: SignatureDeclaration) {
emitJsDocComments(node);
write("new ");
emitSignatureDeclaration(node);
}
function emitSignatureDeclaration(node: SignatureDeclaration) {
if (node.kind === SyntaxKind.CallSignature || node.kind === SyntaxKind.IndexSignature) {
// Only index and call signatures are emitted directly, so emit their js doc comments, rest will do that in their own functions
emitJsDocComments(node);
}
emitTypeParameters(node.typeParameters);
if (node.kind === SyntaxKind.IndexSignature) {
write("[");

View File

@ -117,11 +117,14 @@ interface i2 {
x: number;
/** this is foo*/
foo: (b: number) => string;
/** this is indexer*/
[i: string]: any;
/**new method*/
new (i: i1): any;
nc_x: number;
nc_foo: (b: number) => string;
[i: number]: number;
/** this is call signature*/
(a: number, b: number): number;
/** this is fnfoo*/
fnfoo(b: number): string;

View File

@ -274,7 +274,9 @@ declare function f4(a: number): number;
/** this is signature 4 - with string parameter*/
declare function f4(b: string): number;
interface i1 {
/**this signature 1*/
(a: number): number;
/**this is signature 2*/
(b: string): number;
/** foo 1*/
foo(a: number): number;
@ -294,19 +296,25 @@ interface i1 {
/** foo4 any */
foo4(c: any): any;
new (a: string): any;
/** new 1*/
new (b: number): any;
}
declare var i1_i: i1;
interface i2 {
new (a: string): any;
/** new 2*/
new (b: number): any;
(a: number): number;
/**this is signature 2*/
(b: string): number;
}
declare var i2_i: i2;
interface i3 {
/** new 1*/
new (a: string): any;
/** new 2*/
new (b: number): any;
/**this is signature 1*/
(a: number): number;
(b: string): number;
}

View File

@ -172,8 +172,11 @@ declare class c {
declare var i: c;
/** interface comments*/
interface i1 {
/** caller comments*/
(a: number): number;
/** new comments*/
new (b: string): any;
/**indexer property*/
[a: number]: string;
/** function property;*/
myFoo(a: number): string;

View File

@ -71,9 +71,11 @@ interface IGlobalCallSignatureWithOwnTypeParametes {
//// [declFileCallSignatures_0.d.ts]
export interface ICallSignature {
/** This comment should appear for foo*/
(): string;
}
export interface ICallSignatureWithParameters {
/** This is comment for function signature*/
(a: string, b: number): void;
}
export interface ICallSignatureWithRestParameters {
@ -84,6 +86,7 @@ export interface ICallSignatureWithOverloads {
(a: number): number;
}
export interface ICallSignatureWithTypeParameters<T> {
/** This comment should appear for foo*/
(a: T): string;
}
export interface ICallSignatureWithOwnTypeParametes {
@ -91,9 +94,11 @@ export interface ICallSignatureWithOwnTypeParametes {
}
//// [declFileCallSignatures_1.d.ts]
interface IGlobalCallSignature {
/** This comment should appear for foo*/
(): string;
}
interface IGlobalCallSignatureWithParameters {
/** This is comment for function signature*/
(a: string, b: number): void;
}
interface IGlobalCallSignatureWithRestParameters {
@ -104,6 +109,7 @@ interface IGlobalCallSignatureWithOverloads {
(a: number): number;
}
interface IGlobalCallSignatureWithTypeParameters<T> {
/** This comment should appear for foo*/
(a: T): string;
}
interface IGlobalCallSignatureWithOwnTypeParametes {

View File

@ -71,9 +71,11 @@ interface IGlobalConstructSignatureWithOwnTypeParametes {
//// [declFileConstructSignatures_0.d.ts]
export interface IConstructSignature {
/** This comment should appear for foo*/
new (): string;
}
export interface IConstructSignatureWithParameters {
/** This is comment for function signature*/
new (a: string, b: number): any;
}
export interface IConstructSignatureWithRestParameters {
@ -84,6 +86,7 @@ export interface IConstructSignatureWithOverloads {
new (a: number): number;
}
export interface IConstructSignatureWithTypeParameters<T> {
/** This comment should appear for foo*/
new (a: T): T;
}
export interface IConstructSignatureWithOwnTypeParametes {
@ -91,9 +94,11 @@ export interface IConstructSignatureWithOwnTypeParametes {
}
//// [declFileConstructSignatures_1.d.ts]
interface IGlobalConstructSignature {
/** This comment should appear for foo*/
new (): string;
}
interface IGlobalConstructSignatureWithParameters {
/** This is comment for function signature*/
new (a: string, b: number): any;
}
interface IGlobalConstructSignatureWithRestParameters {
@ -104,6 +109,7 @@ interface IGlobalConstructSignatureWithOverloads {
new (a: number): number;
}
interface IGlobalConstructSignatureWithTypeParameters<T> {
/** This comment should appear for foo*/
new (a: T): T;
}
interface IGlobalConstructSignatureWithOwnTypeParametes {