TypeScript/tests/baselines/reference/commentsFunction.types
2014-08-27 16:58:31 -07:00

125 lines
3 KiB
Text

=== tests/cases/compiler/commentsFunction.ts ===
/** This comment should appear for foo*/
function foo() {
>foo : typeof foo
} /* trailing comment of function */
foo();
>foo() : void
>foo : typeof foo
/** This is comment for function signature*/
function fooWithParameters(/** this is comment about a*/a: string,
>fooWithParameters : typeof fooWithParameters
>a : string
/** this is comment for b*/
b: number) {
>b : number
var d = a;
>d : string
>a : string
} // trailing comment of function
fooWithParameters("a", 10);
>fooWithParameters("a", 10) : void
>fooWithParameters : typeof fooWithParameters
/** fooFunc
* comment
*/
var fooFunc = function FooFunctionValue(/** fooFunctionValue param */ b: string) {
>fooFunc : (b: string) => string
>function FooFunctionValue(/** fooFunctionValue param */ b: string) { return b;} : (b: string) => string
>FooFunctionValue : (b: string) => string
>b : string
return b;
>b : string
}
/// lamdaFoo var comment
var lambdaFoo = /** this is lambda comment*/ (/**param a*/a: number, /**param b*/b: number) => a + b;
>lambdaFoo : (a: number, b: number) => number
>(/**param a*/a: number, /**param b*/b: number) => a + b : (a: number, b: number) => number
>a : number
>b : number
>a + b : number
>a : number
>b : number
var lambddaNoVarComment = /** this is lambda multiplication*/ (/**param a*/a: number, /**param b*/b: number) => a * b;
>lambddaNoVarComment : (a: number, b: number) => number
>(/**param a*/a: number, /**param b*/b: number) => a * b : (a: number, b: number) => number
>a : number
>b : number
>a * b : number
>a : number
>b : number
lambdaFoo(10, 20);
>lambdaFoo(10, 20) : number
>lambdaFoo : (a: number, b: number) => number
lambddaNoVarComment(10, 20);
>lambddaNoVarComment(10, 20) : number
>lambddaNoVarComment : (a: number, b: number) => number
function blah(a: string /* multiline trailing comment
>blah : typeof blah
>a : string
multiline */) {
}
function blah2(a: string /* single line multiple trailing comments */ /* second */) {
>blah2 : typeof blah2
>a : string
}
function blah3(a: string // trailing commen single line
>blah3 : typeof blah3
>a : string
) {
}
lambdaFoo = (a, b) => a * b; // This is trailing comment
>lambdaFoo = (a, b) => a * b : (a: number, b: number) => number
>lambdaFoo : (a: number, b: number) => number
>(a, b) => a * b : (a: number, b: number) => number
>a : number
>b : number
>a * b : number
>a : number
>b : number
/*leading comment*/() => 0; // Needs to be wrapped in parens to be a valid expression (not declaration)
>() => 0 : () => number
/*leading comment*/(() => 0); //trailing comment
>(() => 0) : () => number
>() => 0 : () => number
function blah4(/*1*/a: string/*2*/,/*3*/b: string/*4*/) {
>blah4 : typeof blah4
>a : string
>b : string
}
function foo1() {
>foo1 : typeof foo1
// should emit this
}
function foo2() {
>foo2 : typeof foo2
/// This is some detached comment
// should emit this leading comment of } too
}