mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-26 20:14:05 -05:00
Merge pull request #455 from Microsoft/formatComment
Align the multiline comments in the generated outputs by retaining its position relative to the first line in the comment
This commit is contained in:
@@ -121,16 +121,16 @@ var C3 = (function () {
|
||||
};
|
||||
return C3;
|
||||
})();
|
||||
/*
|
||||
|
||||
This behaves unexpectedly with the following types:
|
||||
|
||||
Type 1 of any[]:
|
||||
|
||||
* Type 2 of the following throws an error but shouldn't: () => void[], SomeClass[], and {one: 1}[].
|
||||
|
||||
* Type 2 of the following doesn't throw an error but should: {one: 1}, new() => SomeClass, SomeClass.
|
||||
|
||||
/*
|
||||
|
||||
This behaves unexpectedly with the following types:
|
||||
|
||||
Type 1 of any[]:
|
||||
|
||||
* Type 2 of the following throws an error but shouldn't: () => void[], SomeClass[], and {one: 1}[].
|
||||
|
||||
* Type 2 of the following doesn't throw an error but should: {one: 1}, new() => SomeClass, SomeClass.
|
||||
|
||||
*/
|
||||
var a1 = null;
|
||||
var c1 = new C1();
|
||||
|
||||
@@ -95,16 +95,16 @@ var C3 = (function () {
|
||||
};
|
||||
return C3;
|
||||
})();
|
||||
/*
|
||||
|
||||
This behaves unexpectedly with the following types:
|
||||
|
||||
Type 1 of any[]:
|
||||
|
||||
* Type 2 of the following throws an error but shouldn't: () => void[], SomeClass[], and {one: 1}[].
|
||||
|
||||
* Type 2 of the following doesn't throw an error but should: {one: 1}, new() => SomeClass, SomeClass.
|
||||
|
||||
/*
|
||||
|
||||
This behaves unexpectedly with the following types:
|
||||
|
||||
Type 1 of any[]:
|
||||
|
||||
* Type 2 of the following throws an error but shouldn't: () => void[], SomeClass[], and {one: 1}[].
|
||||
|
||||
* Type 2 of the following doesn't throw an error but should: {one: 1}, new() => SomeClass, SomeClass.
|
||||
|
||||
*/
|
||||
var a1 = null;
|
||||
var c1 = new C1();
|
||||
|
||||
@@ -35,16 +35,16 @@ var C3 = (function () {
|
||||
};
|
||||
return C3;
|
||||
})();
|
||||
/*
|
||||
|
||||
This behaves unexpectedly with teh following types:
|
||||
|
||||
Type 1 of any[]:
|
||||
|
||||
* Type 2 of the following throws an error but shouldn't: () => void[], SomeClass[], and {one: 1}[].
|
||||
|
||||
* Type 2 of the following doesn't throw an error but should: {one: 1}, new() => SomeClass, SomeClass.
|
||||
|
||||
/*
|
||||
|
||||
This behaves unexpectedly with teh following types:
|
||||
|
||||
Type 1 of any[]:
|
||||
|
||||
* Type 2 of the following throws an error but shouldn't: () => void[], SomeClass[], and {one: 1}[].
|
||||
|
||||
* Type 2 of the following doesn't throw an error but should: {one: 1}, new() => SomeClass, SomeClass.
|
||||
|
||||
*/
|
||||
var c3 = new C3();
|
||||
var o1 = { one: 1 };
|
||||
|
||||
@@ -12,9 +12,9 @@ class C {
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
/**
|
||||
* Returns bar
|
||||
*/
|
||||
/**
|
||||
* Returns bar
|
||||
*/
|
||||
C.foo = function () {
|
||||
return "bar";
|
||||
};
|
||||
|
||||
@@ -11,8 +11,8 @@ class WebControls {
|
||||
var WebControls = (function () {
|
||||
function WebControls() {
|
||||
}
|
||||
/**
|
||||
* Render a control
|
||||
/**
|
||||
* Render a control
|
||||
*/
|
||||
WebControls.prototype.createControl = function () {
|
||||
};
|
||||
|
||||
@@ -117,10 +117,10 @@ var c7 = (function () {
|
||||
})();
|
||||
var i7 = new c7();
|
||||
var i7_c = c7;
|
||||
/** class with statics and constructor
|
||||
/** class with statics and constructor
|
||||
*/
|
||||
var c8 = (function () {
|
||||
/** constructor comment
|
||||
/** constructor comment
|
||||
*/
|
||||
function c8() {
|
||||
}
|
||||
@@ -167,12 +167,12 @@ declare class c7 {
|
||||
}
|
||||
declare var i7: c7;
|
||||
declare var i7_c: typeof c7;
|
||||
/** class with statics and constructor
|
||||
/** class with statics and constructor
|
||||
*/
|
||||
declare class c8 {
|
||||
/** s1 comment */
|
||||
static s1: number;
|
||||
/** constructor comment
|
||||
/** constructor comment
|
||||
*/
|
||||
constructor();
|
||||
}
|
||||
|
||||
@@ -398,13 +398,13 @@ var c1 = (function () {
|
||||
return c1.b_s1 + b;
|
||||
};
|
||||
Object.defineProperty(c1, "b_s3", {
|
||||
/** static getter property
|
||||
*/
|
||||
/** static getter property
|
||||
*/
|
||||
get: function () {
|
||||
return c1.s2(c1.s1);
|
||||
},
|
||||
/** setter property
|
||||
*/
|
||||
/** setter property
|
||||
*/
|
||||
set: function (value) {
|
||||
/** setter */
|
||||
c1.b_s1 = c1.b_s2(value);
|
||||
@@ -541,9 +541,9 @@ declare class c1 {
|
||||
static b_s1: number;
|
||||
/** static sum with property */
|
||||
static b_s2(b: number): number;
|
||||
/** static getter property
|
||||
/** static getter property
|
||||
*/
|
||||
/** setter property
|
||||
/** setter property
|
||||
*/
|
||||
static b_s3: number;
|
||||
}
|
||||
|
||||
@@ -169,16 +169,16 @@ multiLine();
|
||||
function jsDocSingleLine() {
|
||||
}
|
||||
jsDocSingleLine();
|
||||
/** this is multiple line jsdoc stule comment
|
||||
*New line1
|
||||
/** this is multiple line jsdoc stule comment
|
||||
*New line1
|
||||
*New Line2*/
|
||||
function jsDocMultiLine() {
|
||||
}
|
||||
jsDocMultiLine();
|
||||
/** this is multiple line jsdoc stule comment
|
||||
*New line1
|
||||
/** this is multiple line jsdoc stule comment
|
||||
*New line1
|
||||
*New Line2*/
|
||||
/** Shoul mege this line as well
|
||||
/** Shoul mege this line as well
|
||||
* and this too*/ /** Another this one too*/
|
||||
function jsDocMultiLineMerge() {
|
||||
}
|
||||
@@ -230,9 +230,9 @@ noHelpComment2();
|
||||
function noHelpComment3() {
|
||||
}
|
||||
noHelpComment3();
|
||||
/** Adds two integers and returns the result
|
||||
* @param {number} a first number
|
||||
* @param b second number
|
||||
/** Adds two integers and returns the result
|
||||
* @param {number} a first number
|
||||
* @param b second number
|
||||
*/
|
||||
function sum(a, b) {
|
||||
return a + b;
|
||||
@@ -242,7 +242,7 @@ sum(10, 20);
|
||||
/** @param */
|
||||
/** @param a first number*/
|
||||
/** @param b */
|
||||
/** @param c {
|
||||
/** @param c {
|
||||
@param d @anotherTag*/
|
||||
/** @param e LastParam @anotherTag*/
|
||||
function multiply(a, b, c, d, e) {
|
||||
@@ -251,34 +251,34 @@ function multiply(a, b, c, d, e) {
|
||||
function f1(aOrb, opt) {
|
||||
return aOrb;
|
||||
}
|
||||
/** 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
|
||||
/** 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
|
||||
*/
|
||||
function subtract(a, b, c, d, e, f) {
|
||||
}
|
||||
/** 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
|
||||
/** 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
|
||||
*/
|
||||
function square(a) {
|
||||
return a * a;
|
||||
}
|
||||
/** this is divide function
|
||||
@param { number} a this is a
|
||||
@paramTag { number } g this is optional param g
|
||||
@param { number} b this is b
|
||||
/** this is divide function
|
||||
@param { number} a this is a
|
||||
@paramTag { number } g this is optional param g
|
||||
@param { number} b this is b
|
||||
*/
|
||||
function divide(a, b) {
|
||||
}
|
||||
/** 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
|
||||
/** 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
|
||||
*/
|
||||
function jsDocParamTest(a, b, c, d) {
|
||||
return a + b + c + d;
|
||||
@@ -296,14 +296,14 @@ 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
|
||||
/** this is multiple line jsdoc stule comment
|
||||
*New line1
|
||||
*New Line2*/
|
||||
declare function jsDocMultiLine(): void;
|
||||
/** this is multiple line jsdoc stule comment
|
||||
*New line1
|
||||
/** this is multiple line jsdoc stule comment
|
||||
*New line1
|
||||
*New Line2*/
|
||||
/** Shoul mege this line as well
|
||||
/** Shoul mege this line as well
|
||||
* and this too*/ /** Another this one too*/
|
||||
declare function jsDocMultiLineMerge(): void;
|
||||
/** jsdoc comment */
|
||||
@@ -322,48 +322,48 @@ 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
|
||||
/** 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 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
|
||||
/** 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
|
||||
/** 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
|
||||
/** 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
|
||||
/** 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
|
||||
/** 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(/** this is inline comment for a */ a: number, /** this is inline comment for b*/ b: number, c: number, d: number): number;
|
||||
declare class NoQuickInfoClass {
|
||||
|
||||
@@ -98,13 +98,13 @@ define(["require", "exports"], function (require, exports) {
|
||||
(function (m4) {
|
||||
/** b's comment */
|
||||
m4.b;
|
||||
/** foo's comment
|
||||
*/
|
||||
/** foo's comment
|
||||
*/
|
||||
function foo() {
|
||||
return m4.b;
|
||||
}
|
||||
/** m2 comments
|
||||
*/
|
||||
/** m2 comments
|
||||
*/
|
||||
(function (m2) {
|
||||
/** class comment; */
|
||||
var c = (function () {
|
||||
@@ -157,7 +157,7 @@ export declare module m1 {
|
||||
export declare module m4 {
|
||||
/** b's comment */
|
||||
var b: number;
|
||||
/** m2 comments
|
||||
/** m2 comments
|
||||
*/
|
||||
module m2 {
|
||||
/** class comment; */
|
||||
|
||||
@@ -98,13 +98,13 @@ define(["require", "exports"], function (require, exports) {
|
||||
(function (m4) {
|
||||
/** b's comment */
|
||||
m4.b;
|
||||
/** foo's comment
|
||||
*/
|
||||
/** foo's comment
|
||||
*/
|
||||
function foo() {
|
||||
return m4.b;
|
||||
}
|
||||
/** m2 comments
|
||||
*/
|
||||
/** m2 comments
|
||||
*/
|
||||
(function (m2) {
|
||||
/** class comment; */
|
||||
var c = (function () {
|
||||
@@ -157,7 +157,7 @@ export declare module m1 {
|
||||
export declare module m4 {
|
||||
/** b's comment */
|
||||
var b: number;
|
||||
/** m2 comments
|
||||
/** m2 comments
|
||||
*/
|
||||
module m2 {
|
||||
/** class comment; */
|
||||
|
||||
220
tests/baselines/reference/commentsFormatting.js
Normal file
220
tests/baselines/reference/commentsFormatting.js
Normal file
@@ -0,0 +1,220 @@
|
||||
//// [commentsFormatting.ts]
|
||||
|
||||
module m {
|
||||
/** this is first line - aligned to class declaration
|
||||
* this is 4 spaces left aligned
|
||||
* this is 3 spaces left aligned
|
||||
* this is 2 spaces left aligned
|
||||
* this is 1 spaces left aligned
|
||||
* this is at same level as first line
|
||||
* this is 1 spaces right aligned
|
||||
* this is 2 spaces right aligned
|
||||
* this is 3 spaces right aligned
|
||||
* this is 4 spaces right aligned
|
||||
* this is 5 spaces right aligned
|
||||
* this is 6 spaces right aligned
|
||||
* this is 7 spaces right aligned
|
||||
* this is 8 spaces right aligned */
|
||||
export class c {
|
||||
}
|
||||
|
||||
/** this is first line - 4 spaces right aligned to class but in js file should be aligned to class declaration
|
||||
* this is 8 spaces left aligned
|
||||
* this is 7 spaces left aligned
|
||||
* this is 6 spaces left aligned
|
||||
* this is 5 spaces left aligned
|
||||
* this is 4 spaces left aligned
|
||||
* this is 3 spaces left aligned
|
||||
* this is 2 spaces left aligned
|
||||
* this is 1 spaces left aligned
|
||||
* this is at same level as first line
|
||||
* this is 1 spaces right aligned
|
||||
* this is 2 spaces right aligned
|
||||
* this is 3 spaces right aligned
|
||||
* this is 4 spaces right aligned
|
||||
* this is 5 spaces right aligned
|
||||
* this is 6 spaces right aligned
|
||||
* this is 7 spaces right aligned
|
||||
* this is 8 spaces right aligned */
|
||||
export class c2 {
|
||||
}
|
||||
|
||||
/** this is comment with new lines in between
|
||||
|
||||
this is 4 spaces left aligned but above line is empty
|
||||
|
||||
this is 3 spaces left aligned but above line is empty
|
||||
|
||||
this is 2 spaces left aligned but above line is empty
|
||||
|
||||
this is 1 spaces left aligned but above line is empty
|
||||
|
||||
this is at same level as first line but above line is empty
|
||||
|
||||
this is 1 spaces right aligned but above line is empty
|
||||
|
||||
this is 2 spaces right aligned but above line is empty
|
||||
|
||||
this is 3 spaces right aligned but above line is empty
|
||||
|
||||
this is 4 spaces right aligned but above line is empty
|
||||
|
||||
|
||||
Above 2 lines are empty
|
||||
|
||||
|
||||
|
||||
above 3 lines are empty*/
|
||||
export class c3 {
|
||||
}
|
||||
}
|
||||
|
||||
//// [commentsFormatting.js]
|
||||
var m;
|
||||
(function (m) {
|
||||
/** this is first line - aligned to class declaration
|
||||
* this is 4 spaces left aligned
|
||||
* this is 3 spaces left aligned
|
||||
* this is 2 spaces left aligned
|
||||
* this is 1 spaces left aligned
|
||||
* this is at same level as first line
|
||||
* this is 1 spaces right aligned
|
||||
* this is 2 spaces right aligned
|
||||
* this is 3 spaces right aligned
|
||||
* this is 4 spaces right aligned
|
||||
* this is 5 spaces right aligned
|
||||
* this is 6 spaces right aligned
|
||||
* this is 7 spaces right aligned
|
||||
* this is 8 spaces right aligned */
|
||||
var c = (function () {
|
||||
function c() {
|
||||
}
|
||||
return c;
|
||||
})();
|
||||
m.c = c;
|
||||
/** this is first line - 4 spaces right aligned to class but in js file should be aligned to class declaration
|
||||
* this is 8 spaces left aligned
|
||||
* this is 7 spaces left aligned
|
||||
* this is 6 spaces left aligned
|
||||
* this is 5 spaces left aligned
|
||||
* this is 4 spaces left aligned
|
||||
* this is 3 spaces left aligned
|
||||
* this is 2 spaces left aligned
|
||||
* this is 1 spaces left aligned
|
||||
* this is at same level as first line
|
||||
* this is 1 spaces right aligned
|
||||
* this is 2 spaces right aligned
|
||||
* this is 3 spaces right aligned
|
||||
* this is 4 spaces right aligned
|
||||
* this is 5 spaces right aligned
|
||||
* this is 6 spaces right aligned
|
||||
* this is 7 spaces right aligned
|
||||
* this is 8 spaces right aligned */
|
||||
var c2 = (function () {
|
||||
function c2() {
|
||||
}
|
||||
return c2;
|
||||
})();
|
||||
m.c2 = c2;
|
||||
/** this is comment with new lines in between
|
||||
|
||||
this is 4 spaces left aligned but above line is empty
|
||||
|
||||
this is 3 spaces left aligned but above line is empty
|
||||
|
||||
this is 2 spaces left aligned but above line is empty
|
||||
|
||||
this is 1 spaces left aligned but above line is empty
|
||||
|
||||
this is at same level as first line but above line is empty
|
||||
|
||||
this is 1 spaces right aligned but above line is empty
|
||||
|
||||
this is 2 spaces right aligned but above line is empty
|
||||
|
||||
this is 3 spaces right aligned but above line is empty
|
||||
|
||||
this is 4 spaces right aligned but above line is empty
|
||||
|
||||
|
||||
Above 2 lines are empty
|
||||
|
||||
|
||||
|
||||
above 3 lines are empty*/
|
||||
var c3 = (function () {
|
||||
function c3() {
|
||||
}
|
||||
return c3;
|
||||
})();
|
||||
m.c3 = c3;
|
||||
})(m || (m = {}));
|
||||
|
||||
|
||||
//// [commentsFormatting.d.ts]
|
||||
declare module m {
|
||||
/** this is first line - aligned to class declaration
|
||||
* this is 4 spaces left aligned
|
||||
* this is 3 spaces left aligned
|
||||
* this is 2 spaces left aligned
|
||||
* this is 1 spaces left aligned
|
||||
* this is at same level as first line
|
||||
* this is 1 spaces right aligned
|
||||
* this is 2 spaces right aligned
|
||||
* this is 3 spaces right aligned
|
||||
* this is 4 spaces right aligned
|
||||
* this is 5 spaces right aligned
|
||||
* this is 6 spaces right aligned
|
||||
* this is 7 spaces right aligned
|
||||
* this is 8 spaces right aligned */
|
||||
class c {
|
||||
}
|
||||
/** this is first line - 4 spaces right aligned to class but in js file should be aligned to class declaration
|
||||
* this is 8 spaces left aligned
|
||||
* this is 7 spaces left aligned
|
||||
* this is 6 spaces left aligned
|
||||
* this is 5 spaces left aligned
|
||||
* this is 4 spaces left aligned
|
||||
* this is 3 spaces left aligned
|
||||
* this is 2 spaces left aligned
|
||||
* this is 1 spaces left aligned
|
||||
* this is at same level as first line
|
||||
* this is 1 spaces right aligned
|
||||
* this is 2 spaces right aligned
|
||||
* this is 3 spaces right aligned
|
||||
* this is 4 spaces right aligned
|
||||
* this is 5 spaces right aligned
|
||||
* this is 6 spaces right aligned
|
||||
* this is 7 spaces right aligned
|
||||
* this is 8 spaces right aligned */
|
||||
class c2 {
|
||||
}
|
||||
/** this is comment with new lines in between
|
||||
|
||||
this is 4 spaces left aligned but above line is empty
|
||||
|
||||
this is 3 spaces left aligned but above line is empty
|
||||
|
||||
this is 2 spaces left aligned but above line is empty
|
||||
|
||||
this is 1 spaces left aligned but above line is empty
|
||||
|
||||
this is at same level as first line but above line is empty
|
||||
|
||||
this is 1 spaces right aligned but above line is empty
|
||||
|
||||
this is 2 spaces right aligned but above line is empty
|
||||
|
||||
this is 3 spaces right aligned but above line is empty
|
||||
|
||||
this is 4 spaces right aligned but above line is empty
|
||||
|
||||
|
||||
Above 2 lines are empty
|
||||
|
||||
|
||||
|
||||
above 3 lines are empty*/
|
||||
class c3 {
|
||||
}
|
||||
}
|
||||
@@ -52,8 +52,8 @@ function fooWithParameters(a,
|
||||
var d = a;
|
||||
} // trailing comment of function
|
||||
fooWithParameters("a", 10);
|
||||
/** fooFunc
|
||||
* comment
|
||||
/** fooFunc
|
||||
* comment
|
||||
*/
|
||||
var fooFunc = function FooFunctionValue(b) {
|
||||
return b;
|
||||
@@ -83,8 +83,8 @@ declare function foo(): void;
|
||||
declare function fooWithParameters(/** this is comment about a*/ a: string,
|
||||
/** this is comment for b*/
|
||||
b: number): void;
|
||||
/** fooFunc
|
||||
* comment
|
||||
/** fooFunc
|
||||
* comment
|
||||
*/
|
||||
declare var fooFunc: (b: string) => string;
|
||||
declare var lambdaFoo: (a: number, b: number) => number;
|
||||
|
||||
@@ -373,8 +373,8 @@ interface i2 {
|
||||
interface i3 extends i2 {
|
||||
/** i3 p1 */
|
||||
p1: number;
|
||||
/**
|
||||
* i3 f1
|
||||
/**
|
||||
* i3 f1
|
||||
*/
|
||||
f1(): void;
|
||||
/** i3 l1*/
|
||||
|
||||
@@ -130,14 +130,14 @@ var m1;
|
||||
function foo2Export(a) {
|
||||
}
|
||||
m1.foo2Export = foo2Export;
|
||||
/** foo3Export
|
||||
* comment
|
||||
/** foo3Export
|
||||
* comment
|
||||
*/
|
||||
function foo3Export() {
|
||||
}
|
||||
m1.foo3Export = foo3Export;
|
||||
/** foo4Export
|
||||
* comment
|
||||
/** foo4Export
|
||||
* comment
|
||||
*/
|
||||
function foo4Export() {
|
||||
}
|
||||
@@ -286,8 +286,8 @@ declare module m1 {
|
||||
/** exported function*/
|
||||
function fooExport(): number;
|
||||
function foo2Export(/**hm*/ a: string): void;
|
||||
/** foo3Export
|
||||
* comment
|
||||
/** foo3Export
|
||||
* comment
|
||||
*/
|
||||
function foo3Export(): void;
|
||||
}
|
||||
|
||||
@@ -14,11 +14,11 @@ var Person = makeClass(
|
||||
|
||||
//// [commentsOnObjectLiteral2.js]
|
||||
var Person = makeClass({
|
||||
/**
|
||||
This is just another way to define a constructor.
|
||||
@constructs
|
||||
@param {string} name The name of the person.
|
||||
*/
|
||||
/**
|
||||
This is just another way to define a constructor.
|
||||
@constructs
|
||||
@param {string} name The name of the person.
|
||||
*/
|
||||
initialize: function (name) {
|
||||
this.name = name;
|
||||
} /* trailing comment 1*/
|
||||
|
||||
@@ -24,12 +24,12 @@ class test {
|
||||
var test = (function () {
|
||||
function test() {
|
||||
}
|
||||
/**
|
||||
* p1 comment appears in output
|
||||
/**
|
||||
* p1 comment appears in output
|
||||
*/
|
||||
test.p1 = "";
|
||||
/**
|
||||
* p3 comment appears in output
|
||||
/**
|
||||
* p3 comment appears in output
|
||||
*/
|
||||
test.p3 = "";
|
||||
return test;
|
||||
|
||||
@@ -50,7 +50,7 @@ var myVariable = 10; // This trailing Comment1
|
||||
var anotherVariable = 30;
|
||||
// shouldn't appear
|
||||
var aVar = "";
|
||||
/** this is multiline comment
|
||||
/** this is multiline comment
|
||||
* All these variables are of number type */
|
||||
var anotherAnotherVariable = 70; /* these are multiple trailing comments */ /* multiple trailing comments */
|
||||
/** Triple slash multiline comment*/
|
||||
@@ -81,7 +81,7 @@ declare var myVariable: number;
|
||||
/** This is another variable comment*/
|
||||
declare var anotherVariable: number;
|
||||
declare var aVar: string;
|
||||
/** this is multiline comment
|
||||
/** this is multiline comment
|
||||
* All these variables are of number type */
|
||||
declare var anotherAnotherVariable: number;
|
||||
/** Triple slash multiline comment*/
|
||||
|
||||
@@ -34,11 +34,11 @@ c = c.m(cc);
|
||||
|
||||
//// [concatError.js]
|
||||
var n1;
|
||||
/*
|
||||
interface Array<T> {
|
||||
concat(...items: T[][]): T[]; // Note: This overload needs to be picked for arrays of arrays, even though both are applicable
|
||||
concat(...items: T[]): T[];
|
||||
}
|
||||
/*
|
||||
interface Array<T> {
|
||||
concat(...items: T[][]): T[]; // Note: This overload needs to be picked for arrays of arrays, even though both are applicable
|
||||
concat(...items: T[]): T[];
|
||||
}
|
||||
*/
|
||||
var fa;
|
||||
fa = fa.concat([0]);
|
||||
|
||||
@@ -120,15 +120,15 @@ l\u0061bel4:
|
||||
}
|
||||
|
||||
//// [escapedIdentifiers.js]
|
||||
/*
|
||||
0 .. \u0030
|
||||
9 .. \u0039
|
||||
|
||||
A .. \u0041
|
||||
Z .. \u005a
|
||||
|
||||
a .. \u0061
|
||||
z .. \u00za
|
||||
/*
|
||||
0 .. \u0030
|
||||
9 .. \u0039
|
||||
|
||||
A .. \u0041
|
||||
Z .. \u005a
|
||||
|
||||
a .. \u0061
|
||||
z .. \u00za
|
||||
*/
|
||||
// var decl
|
||||
var \u0061 = 1;
|
||||
|
||||
@@ -15,16 +15,16 @@ var lengths = ["a", "b", "c"].map(x => x.length);
|
||||
|
||||
|
||||
//// [genericArray1.js]
|
||||
/*
|
||||
var n: number[];
|
||||
|
||||
interface Array<T> {
|
||||
map<U>(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[];
|
||||
}
|
||||
|
||||
interface String{
|
||||
length: number;
|
||||
}
|
||||
/*
|
||||
var n: number[];
|
||||
|
||||
interface Array<T> {
|
||||
map<U>(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[];
|
||||
}
|
||||
|
||||
interface String{
|
||||
length: number;
|
||||
}
|
||||
*/
|
||||
var lengths = ["a", "b", "c"].map(function (x) { return x.length; });
|
||||
|
||||
|
||||
@@ -64,8 +64,8 @@ var a = function () {
|
||||
return new C2();
|
||||
};
|
||||
new a();
|
||||
/*var b:I4 = C2;
|
||||
new b();
|
||||
/*var b:I4 = C2;
|
||||
new b();
|
||||
*/
|
||||
var c;
|
||||
c[5];
|
||||
|
||||
@@ -45,11 +45,11 @@ var IceCreamMonster = (function () {
|
||||
this.soundsWhenEating = soundsWhenEating;
|
||||
this.name = name;
|
||||
}
|
||||
/**
|
||||
* Tells the IceCreamMonster to eat their ice cre am!
|
||||
*
|
||||
* @param {number} amount The amount of ice cream to e at.
|
||||
* @return {boolean} True if ice cream remains, false if there is no more ice cream le ft.
|
||||
/**
|
||||
* Tells the IceCreamMonster to eat their ice cre am!
|
||||
*
|
||||
* @param {number} amount The amount of ice cream to e at.
|
||||
* @return {boolean} True if ice cream remains, false if there is no more ice cream le ft.
|
||||
*/
|
||||
IceCreamMonster.prototype.eatIceCream = function (amount) {
|
||||
this.iceCreamRemaining -= amount;
|
||||
|
||||
@@ -32,9 +32,9 @@ runTestCase(testcase);
|
||||
/// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the
|
||||
/// "Use Terms"). Any redistribution of this code must retain the above
|
||||
/// copyright and this notice and otherwise comply with the Use Terms.
|
||||
/**
|
||||
* @path ch15/15.4/15.4.4/15.4.4.14/15.4.4.14-9-2.js
|
||||
* @description Array.prototype.indexOf must return correct index (Number)
|
||||
/**
|
||||
* @path ch15/15.4/15.4.4/15.4.4.14/15.4.4.14-9-2.js
|
||||
* @description Array.prototype.indexOf must return correct index (Number)
|
||||
*/
|
||||
function testcase() {
|
||||
var obj = { toString: function () {
|
||||
|
||||
@@ -23,11 +23,11 @@ if (x !== 1) {
|
||||
//// [parserS7.3_A1.1_T2.js]
|
||||
// Copyright 2009 the Sputnik authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/**
|
||||
* LINE FEED (U+000A) may occur between any two tokens
|
||||
*
|
||||
* @path ch07/7.3/S7.3_A1.1_T2.js
|
||||
* @description Insert real LINE FEED between tokens of var x=1
|
||||
/**
|
||||
* LINE FEED (U+000A) may occur between any two tokens
|
||||
*
|
||||
* @path ch07/7.3/S7.3_A1.1_T2.js
|
||||
* @description Insert real LINE FEED between tokens of var x=1
|
||||
*/
|
||||
//CHECK#1
|
||||
var x = 1;
|
||||
|
||||
@@ -148,11 +148,11 @@ if (Ё !== 1) {
|
||||
//// [parserS7.6_A4.2_T1.js]
|
||||
// Copyright 2009 the Sputnik authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/**
|
||||
* Correct interpretation of RUSSIAN ALPHABET
|
||||
*
|
||||
* @path ch07/7.6/S7.6_A4.2_T1.js
|
||||
* @description Check RUSSIAN CAPITAL ALPHABET
|
||||
/**
|
||||
* Correct interpretation of RUSSIAN ALPHABET
|
||||
*
|
||||
* @path ch07/7.6/S7.6_A4.2_T1.js
|
||||
* @description Check RUSSIAN CAPITAL ALPHABET
|
||||
*/
|
||||
//CHECK#А-Я
|
||||
var \u0410 = 1;
|
||||
|
||||
@@ -23,13 +23,13 @@ y
|
||||
//// [parserS7.9_A5.7_T1.js]
|
||||
// Copyright 2009 the Sputnik authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/**
|
||||
* Since LineTerminator(LT) between Postfix Increment/Decrement Operator(I/DO) and operand is not allowed, two IO(just as two DO and their combination)
|
||||
* between two references separated by [LT] after automatic semicolon insertion lead to syntax error
|
||||
*
|
||||
* @path ch07/7.9/S7.9_A5.7_T1.js
|
||||
* @description Try use Variable1 \n ++ \n ++ \n Variable2 construction
|
||||
* @negative
|
||||
/**
|
||||
* Since LineTerminator(LT) between Postfix Increment/Decrement Operator(I/DO) and operand is not allowed, two IO(just as two DO and their combination)
|
||||
* between two references separated by [LT] after automatic semicolon insertion lead to syntax error
|
||||
*
|
||||
* @path ch07/7.9/S7.9_A5.7_T1.js
|
||||
* @description Try use Variable1 \n ++ \n ++ \n Variable2 construction
|
||||
* @negative
|
||||
*/
|
||||
var x = 0, y = 0;
|
||||
var z = x;
|
||||
|
||||
@@ -23,11 +23,11 @@ if (x !== 1) {
|
||||
//// [scannerS7.3_A1.1_T2.js]
|
||||
// Copyright 2009 the Sputnik authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/**
|
||||
* LINE FEED (U+000A) may occur between any two tokens
|
||||
*
|
||||
* @path ch07/7.3/S7.3_A1.1_T2.js
|
||||
* @description Insert real LINE FEED between tokens of var x=1
|
||||
/**
|
||||
* LINE FEED (U+000A) may occur between any two tokens
|
||||
*
|
||||
* @path ch07/7.3/S7.3_A1.1_T2.js
|
||||
* @description Insert real LINE FEED between tokens of var x=1
|
||||
*/
|
||||
//CHECK#1
|
||||
var x = 1;
|
||||
|
||||
@@ -148,11 +148,11 @@ if (Ё !== 1) {
|
||||
//// [scannerS7.6_A4.2_T1.js]
|
||||
// Copyright 2009 the Sputnik authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/**
|
||||
* Correct interpretation of RUSSIAN ALPHABET
|
||||
*
|
||||
* @path ch07/7.6/S7.6_A4.2_T1.js
|
||||
* @description Check RUSSIAN CAPITAL ALPHABET
|
||||
/**
|
||||
* Correct interpretation of RUSSIAN ALPHABET
|
||||
*
|
||||
* @path ch07/7.6/S7.6_A4.2_T1.js
|
||||
* @description Check RUSSIAN CAPITAL ALPHABET
|
||||
*/
|
||||
//CHECK#А-Я
|
||||
var \u0410 = 1;
|
||||
|
||||
@@ -61,8 +61,8 @@ var Shapes;
|
||||
function foo() {
|
||||
}
|
||||
Shapes.foo = foo;
|
||||
/** comment after function
|
||||
* this is another comment
|
||||
/** comment after function
|
||||
* this is another comment
|
||||
*/
|
||||
var b = 10;
|
||||
})(Shapes || (Shapes = {}));
|
||||
|
||||
@@ -465,7 +465,7 @@ sourceFile:sourceMap-FileWithComments.ts
|
||||
3 > ^^^
|
||||
4 > ^^^
|
||||
5 > ^
|
||||
6 > ^^^^^^^^^^->
|
||||
6 > ^^^^^^^^^^^->
|
||||
1->
|
||||
2 > foo
|
||||
3 >
|
||||
@@ -478,7 +478,7 @@ sourceFile:sourceMap-FileWithComments.ts
|
||||
4 >Emitted(24, 21) Source(26, 6) + SourceIndex(0) name (Shapes)
|
||||
5 >Emitted(24, 22) Source(26, 6) + SourceIndex(0) name (Shapes)
|
||||
---
|
||||
>>> /** comment after function
|
||||
>>> /** comment after function
|
||||
1->^^^^
|
||||
2 >
|
||||
3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^->
|
||||
@@ -492,7 +492,7 @@ sourceFile:sourceMap-FileWithComments.ts
|
||||
1->Emitted(25, 5) Source(31, 5) + SourceIndex(0) name (Shapes)
|
||||
2 >Emitted(25, 5) Source(28, 5) + SourceIndex(0) name (Shapes)
|
||||
---
|
||||
>>> * this is another comment
|
||||
>>> * this is another comment
|
||||
>>> */
|
||||
1->^^^^^^
|
||||
2 > ^^^^^^^^^^->
|
||||
|
||||
@@ -15,8 +15,8 @@ function foo() {
|
||||
//// [stradac.js]
|
||||
var x = 10;
|
||||
// C++-style comment
|
||||
/*
|
||||
C-Style comment
|
||||
/*
|
||||
C-Style comment
|
||||
*/
|
||||
function foo() {
|
||||
x++;
|
||||
|
||||
72
tests/cases/compiler/commentsFormatting.ts
Normal file
72
tests/cases/compiler/commentsFormatting.ts
Normal file
@@ -0,0 +1,72 @@
|
||||
// @target: ES5
|
||||
// @declaration: true
|
||||
// @comments: true
|
||||
|
||||
module m {
|
||||
/** this is first line - aligned to class declaration
|
||||
* this is 4 spaces left aligned
|
||||
* this is 3 spaces left aligned
|
||||
* this is 2 spaces left aligned
|
||||
* this is 1 spaces left aligned
|
||||
* this is at same level as first line
|
||||
* this is 1 spaces right aligned
|
||||
* this is 2 spaces right aligned
|
||||
* this is 3 spaces right aligned
|
||||
* this is 4 spaces right aligned
|
||||
* this is 5 spaces right aligned
|
||||
* this is 6 spaces right aligned
|
||||
* this is 7 spaces right aligned
|
||||
* this is 8 spaces right aligned */
|
||||
export class c {
|
||||
}
|
||||
|
||||
/** this is first line - 4 spaces right aligned to class but in js file should be aligned to class declaration
|
||||
* this is 8 spaces left aligned
|
||||
* this is 7 spaces left aligned
|
||||
* this is 6 spaces left aligned
|
||||
* this is 5 spaces left aligned
|
||||
* this is 4 spaces left aligned
|
||||
* this is 3 spaces left aligned
|
||||
* this is 2 spaces left aligned
|
||||
* this is 1 spaces left aligned
|
||||
* this is at same level as first line
|
||||
* this is 1 spaces right aligned
|
||||
* this is 2 spaces right aligned
|
||||
* this is 3 spaces right aligned
|
||||
* this is 4 spaces right aligned
|
||||
* this is 5 spaces right aligned
|
||||
* this is 6 spaces right aligned
|
||||
* this is 7 spaces right aligned
|
||||
* this is 8 spaces right aligned */
|
||||
export class c2 {
|
||||
}
|
||||
|
||||
/** this is comment with new lines in between
|
||||
|
||||
this is 4 spaces left aligned but above line is empty
|
||||
|
||||
this is 3 spaces left aligned but above line is empty
|
||||
|
||||
this is 2 spaces left aligned but above line is empty
|
||||
|
||||
this is 1 spaces left aligned but above line is empty
|
||||
|
||||
this is at same level as first line but above line is empty
|
||||
|
||||
this is 1 spaces right aligned but above line is empty
|
||||
|
||||
this is 2 spaces right aligned but above line is empty
|
||||
|
||||
this is 3 spaces right aligned but above line is empty
|
||||
|
||||
this is 4 spaces right aligned but above line is empty
|
||||
|
||||
|
||||
Above 2 lines are empty
|
||||
|
||||
|
||||
|
||||
above 3 lines are empty*/
|
||||
export class c3 {
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user