134 lines
3.2 KiB
Plaintext
134 lines
3.2 KiB
Plaintext
=== tests/cases/compiler/commentsFunction.ts ===
|
|
|
|
/** This comment should appear for foo*/
|
|
function foo() {
|
|
>foo : () => void
|
|
|
|
} /* trailing comment of function */
|
|
foo();
|
|
>foo() : void
|
|
>foo : () => void
|
|
|
|
/** This is comment for function signature*/
|
|
function fooWithParameters(/** this is comment about a*/a: string,
|
|
>fooWithParameters : (a: string, b: number) => void
|
|
>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 : (a: string, b: number) => void
|
|
>"a" : "a"
|
|
>10 : 10
|
|
|
|
/** 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
|
|
>10 : 10
|
|
>20 : 20
|
|
|
|
lambddaNoVarComment(10, 20);
|
|
>lambddaNoVarComment(10, 20) : number
|
|
>lambddaNoVarComment : (a: number, b: number) => number
|
|
>10 : 10
|
|
>20 : 20
|
|
|
|
function blah(a: string /* multiline trailing comment
|
|
>blah : (a: string) => void
|
|
>a : string
|
|
|
|
multiline */) {
|
|
}
|
|
|
|
function blah2(a: string /* single line multiple trailing comments */ /* second */) {
|
|
>blah2 : (a: string) => void
|
|
>a : string
|
|
}
|
|
|
|
function blah3(a: string // trailing commen single line
|
|
>blah3 : (a: string) => void
|
|
>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
|
|
>0 : 0
|
|
|
|
/*leading comment*/(() => 0); //trailing comment
|
|
>(() => 0) : () => number
|
|
>() => 0 : () => number
|
|
>0 : 0
|
|
|
|
function blah4(/*1*/a: string/*2*/,/*3*/b: string/*4*/) {
|
|
>blah4 : (a: string, b: string) => void
|
|
>a : string
|
|
>b : string
|
|
}
|
|
|
|
function foo1() {
|
|
>foo1 : () => void
|
|
|
|
// should emit this
|
|
}
|
|
|
|
function foo2() {
|
|
>foo2 : () => void
|
|
|
|
/// This is some detached comment
|
|
|
|
// should emit this leading comment of } too
|
|
}
|
|
|