From c949543f497fe1bd68a7bcd2d1abdd355fc897b0 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Thu, 14 Aug 2014 09:38:22 -0700 Subject: [PATCH] Fix the indent for the parameter and typeparameter emit in .d.ts file --- src/compiler/emitter.ts | 4 ++++ tests/baselines/reference/commentsFunction.js | 2 +- .../reference/declFileCallSignatures.js | 4 ++-- .../reference/declFileConstructSignatures.js | 4 ++-- .../reference/declFileConstructors.js | 4 ++-- .../baselines/reference/declFileFunctions.js | 4 ++-- tests/baselines/reference/declFileMethods.js | 20 +++++++++---------- 7 files changed, 23 insertions(+), 19 deletions(-) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 34cf6de57f7..eef3e430809 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -2260,7 +2260,9 @@ module ts { }; } + increaseIndent(); emitJsDocComments(node); + decreaseIndent(); emitSourceTextOfNode(node.name); // If there is constraint present and this is not a type parameter of the private method emit the constraint if (node.constraint && (node.parent.kind !== SyntaxKind.Method || !(node.parent.flags & NodeFlags.Private))) { @@ -2647,6 +2649,7 @@ module ts { } function emitParameterDeclaration(node: ParameterDeclaration) { + increaseIndent(); emitJsDocComments(node); if (node.flags & NodeFlags.Rest) { write("..."); @@ -2655,6 +2658,7 @@ module ts { if (node.initializer || (node.flags & NodeFlags.QuestionMark)) { write("?"); } + decreaseIndent(); if (!(node.parent.flags & NodeFlags.Private)) { write(": "); diff --git a/tests/baselines/reference/commentsFunction.js b/tests/baselines/reference/commentsFunction.js index 3913d59d7b0..8f2bb57679e 100644 --- a/tests/baselines/reference/commentsFunction.js +++ b/tests/baselines/reference/commentsFunction.js @@ -53,7 +53,7 @@ lambddaNoVarComment(10, 20); declare function foo(): void; /** This is comment for function signature*/ declare function fooWithParameters(/** this is comment about a*/ a: string, /** this is comment for b*/ -b: number): void; + b: number): void; /** fooFunc * comment */ diff --git a/tests/baselines/reference/declFileCallSignatures.js b/tests/baselines/reference/declFileCallSignatures.js index cf09607a644..6b2be9bae03 100644 --- a/tests/baselines/reference/declFileCallSignatures.js +++ b/tests/baselines/reference/declFileCallSignatures.js @@ -77,7 +77,7 @@ export interface ICallSignature { export interface ICallSignatureWithParameters { /** This is comment for function signature*/ (/** this is comment about a*/ a: string, /** this is comment for b*/ - b: number): void; + b: number): void; } export interface ICallSignatureWithRestParameters { (a: string, ...rests: string[]): string; @@ -101,7 +101,7 @@ interface IGlobalCallSignature { interface IGlobalCallSignatureWithParameters { /** This is comment for function signature*/ (/** this is comment about a*/ a: string, /** this is comment for b*/ - b: number): void; + 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 48fb9208e9e..4a0643389f4 100644 --- a/tests/baselines/reference/declFileConstructSignatures.js +++ b/tests/baselines/reference/declFileConstructSignatures.js @@ -77,7 +77,7 @@ export interface IConstructSignature { export interface IConstructSignatureWithParameters { /** This is comment for function signature*/ new (/** this is comment about a*/ a: string, /** this is comment for b*/ - b: number): any; + b: number): any; } export interface IConstructSignatureWithRestParameters { new (a: string, ...rests: string[]): string; @@ -101,7 +101,7 @@ interface IGlobalConstructSignature { interface IGlobalConstructSignatureWithParameters { /** This is comment for function signature*/ new (/** this is comment about a*/ a: string, /** this is comment for b*/ - b: number): any; + 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 060b9bf55da..5fba6ffdde3 100644 --- a/tests/baselines/reference/declFileConstructors.js +++ b/tests/baselines/reference/declFileConstructors.js @@ -225,7 +225,7 @@ export declare class SimpleConstructor { export declare class ConstructorWithParameters { /** This is comment for function signature*/ constructor(/** this is comment about a*/ a: string, /** this is comment for b*/ - b: number); + b: number); } export declare class ConstructorWithRestParamters { constructor(a: string, ...rests: string[]); @@ -258,7 +258,7 @@ declare class GlobalSimpleConstructor { declare class GlobalConstructorWithParameters { /** This is comment for function signature*/ constructor(/** this is comment about a*/ a: string, /** this is comment for b*/ - b: number); + 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 2f1b64a6695..5b07da353e5 100644 --- a/tests/baselines/reference/declFileFunctions.js +++ b/tests/baselines/reference/declFileFunctions.js @@ -126,7 +126,7 @@ function globalfooWithOverloads(a) { export declare function foo(): void; /** This is comment for function signature*/ export declare function fooWithParameters(/** this is comment about a*/ a: string, /** this is comment for b*/ -b: number): void; + 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; @@ -135,7 +135,7 @@ export declare function fooWithOverloads(a: number): number; declare function globalfoo(): void; /** This is comment for function signature*/ declare function globalfooWithParameters(/** this is comment about a*/ a: string, /** this is comment for b*/ -b: number): void; + 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 0336e60b6b6..f654402fb51 100644 --- a/tests/baselines/reference/declFileMethods.js +++ b/tests/baselines/reference/declFileMethods.js @@ -355,7 +355,7 @@ export declare class c1 { foo(): void; /** This is comment for function signature*/ fooWithParameters(/** this is comment about a*/ a: string, /** this is comment for b*/ - b: number): void; + b: number): void; fooWithRestParameters(a: string, ...rests: string[]): string; fooWithOverloads(a: string): string; fooWithOverloads(a: number): number; @@ -363,7 +363,7 @@ export declare class c1 { private privateFoo(); /** This is comment for function signature*/ private privateFooWithParameters(/** this is comment about a*/ a, /** this is comment for b*/ - b); + b); private privateFooWithRestParameters(a, ...rests); private privateFooWithOverloads(a); private privateFooWithOverloads(a); @@ -371,7 +371,7 @@ export declare class c1 { static staticFoo(): void; /** This is comment for function signature*/ static staticFooWithParameters(/** this is comment about a*/ a: string, /** this is comment for b*/ - b: number): void; + b: number): void; static staticFooWithRestParameters(a: string, ...rests: string[]): string; static staticFooWithOverloads(a: string): string; static staticFooWithOverloads(a: number): number; @@ -379,7 +379,7 @@ export declare class c1 { private static privateStaticFoo(); /** This is comment for function signature*/ private static privateStaticFooWithParameters(/** this is comment about a*/ a, /** this is comment for b*/ - b); + b); private static privateStaticFooWithRestParameters(a, ...rests); private static privateStaticFooWithOverloads(a); private static privateStaticFooWithOverloads(a); @@ -389,7 +389,7 @@ export interface I1 { foo(): string; /** This is comment for function signature*/ fooWithParameters(/** this is comment about a*/ a: string, /** this is comment for b*/ - b: number): void; + b: number): void; fooWithRestParameters(a: string, ...rests: string[]): string; fooWithOverloads(a: string): string; fooWithOverloads(a: number): number; @@ -400,7 +400,7 @@ declare class c2 { foo(): void; /** This is comment for function signature*/ fooWithParameters(/** this is comment about a*/ a: string, /** this is comment for b*/ - b: number): void; + b: number): void; fooWithRestParameters(a: string, ...rests: string[]): string; fooWithOverloads(a: string): string; fooWithOverloads(a: number): number; @@ -408,7 +408,7 @@ declare class c2 { private privateFoo(); /** This is comment for function signature*/ private privateFooWithParameters(/** this is comment about a*/ a, /** this is comment for b*/ - b); + b); private privateFooWithRestParameters(a, ...rests); private privateFooWithOverloads(a); private privateFooWithOverloads(a); @@ -416,7 +416,7 @@ declare class c2 { static staticFoo(): void; /** This is comment for function signature*/ static staticFooWithParameters(/** this is comment about a*/ a: string, /** this is comment for b*/ - b: number): void; + b: number): void; static staticFooWithRestParameters(a: string, ...rests: string[]): string; static staticFooWithOverloads(a: string): string; static staticFooWithOverloads(a: number): number; @@ -424,7 +424,7 @@ declare class c2 { private static privateStaticFoo(); /** This is comment for function signature*/ private static privateStaticFooWithParameters(/** this is comment about a*/ a, /** this is comment for b*/ - b); + b); private static privateStaticFooWithRestParameters(a, ...rests); private static privateStaticFooWithOverloads(a); private static privateStaticFooWithOverloads(a); @@ -434,7 +434,7 @@ interface I2 { foo(): string; /** This is comment for function signature*/ fooWithParameters(/** this is comment about a*/ a: string, /** this is comment for b*/ - b: number): void; + b: number): void; fooWithRestParameters(a: string, ...rests: string[]): string; fooWithOverloads(a: string): string; fooWithOverloads(a: number): number;