2014-08-15 23:33:16 +02:00
|
|
|
=== tests/cases/compiler/funcdecl.ts ===
|
|
|
|
function simpleFunc() {
|
2014-08-28 21:52:44 +02:00
|
|
|
>simpleFunc : () => string
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
return "this is my simple func";
|
|
|
|
}
|
|
|
|
var simpleFuncVar = simpleFunc;
|
2014-08-28 21:52:44 +02:00
|
|
|
>simpleFuncVar : () => string
|
|
|
|
>simpleFunc : () => string
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
function anotherFuncNoReturn() {
|
2014-08-28 21:52:44 +02:00
|
|
|
>anotherFuncNoReturn : () => void
|
2014-08-15 23:33:16 +02:00
|
|
|
}
|
|
|
|
var anotherFuncNoReturnVar = anotherFuncNoReturn;
|
2014-08-28 21:52:44 +02:00
|
|
|
>anotherFuncNoReturnVar : () => void
|
|
|
|
>anotherFuncNoReturn : () => void
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
function withReturn() : string{
|
2014-08-28 21:52:44 +02:00
|
|
|
>withReturn : () => string
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
return "Hello";
|
|
|
|
}
|
|
|
|
var withReturnVar = withReturn;
|
2014-08-28 21:52:44 +02:00
|
|
|
>withReturnVar : () => string
|
|
|
|
>withReturn : () => string
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
function withParams(a : string) : string{
|
2014-08-28 21:52:44 +02:00
|
|
|
>withParams : (a: string) => string
|
2014-08-15 23:33:16 +02:00
|
|
|
>a : string
|
|
|
|
|
|
|
|
return a;
|
|
|
|
>a : string
|
|
|
|
}
|
|
|
|
var withparamsVar = withParams;
|
2014-08-28 21:52:44 +02:00
|
|
|
>withparamsVar : (a: string) => string
|
|
|
|
>withParams : (a: string) => string
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
function withMultiParams(a : number, b, c: Object) {
|
2014-08-28 21:52:44 +02:00
|
|
|
>withMultiParams : (a: number, b: any, c: Object) => number
|
2014-08-15 23:33:16 +02:00
|
|
|
>a : number
|
|
|
|
>b : any
|
|
|
|
>c : Object
|
|
|
|
>Object : Object
|
|
|
|
|
|
|
|
return a;
|
|
|
|
>a : number
|
|
|
|
}
|
|
|
|
var withMultiParamsVar = withMultiParams;
|
2014-08-28 21:52:44 +02:00
|
|
|
>withMultiParamsVar : (a: number, b: any, c: Object) => number
|
|
|
|
>withMultiParams : (a: number, b: any, c: Object) => number
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
function withOptionalParams(a?: string) {
|
2014-08-28 21:52:44 +02:00
|
|
|
>withOptionalParams : (a?: string) => void
|
2014-08-15 23:33:16 +02:00
|
|
|
>a : string
|
|
|
|
}
|
|
|
|
var withOptionalParamsVar = withOptionalParams;
|
2014-08-28 21:52:44 +02:00
|
|
|
>withOptionalParamsVar : (a?: string) => void
|
|
|
|
>withOptionalParams : (a?: string) => void
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
function withInitializedParams(a: string, b0, b = 30, c = "string value") {
|
2014-08-28 21:52:44 +02:00
|
|
|
>withInitializedParams : (a: string, b0: any, b?: number, c?: string) => void
|
2014-08-15 23:33:16 +02:00
|
|
|
>a : string
|
|
|
|
>b0 : any
|
|
|
|
>b : number
|
|
|
|
>c : string
|
|
|
|
}
|
|
|
|
var withInitializedParamsVar = withInitializedParams;
|
2014-08-28 21:52:44 +02:00
|
|
|
>withInitializedParamsVar : (a: string, b0: any, b?: number, c?: string) => void
|
|
|
|
>withInitializedParams : (a: string, b0: any, b?: number, c?: string) => void
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
function withOptionalInitializedParams(a: string, c: string = "hello string") {
|
2014-08-28 21:52:44 +02:00
|
|
|
>withOptionalInitializedParams : (a: string, c?: string) => void
|
2014-08-15 23:33:16 +02:00
|
|
|
>a : string
|
|
|
|
>c : string
|
|
|
|
}
|
|
|
|
var withOptionalInitializedParamsVar = withOptionalInitializedParams;
|
2014-08-28 21:52:44 +02:00
|
|
|
>withOptionalInitializedParamsVar : (a: string, c?: string) => void
|
|
|
|
>withOptionalInitializedParams : (a: string, c?: string) => void
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
function withRestParams(a: string, ... myRestParameter : number[]) {
|
2014-08-28 21:52:44 +02:00
|
|
|
>withRestParams : (a: string, ...myRestParameter: number[]) => number[]
|
2014-08-15 23:33:16 +02:00
|
|
|
>a : string
|
|
|
|
>myRestParameter : number[]
|
|
|
|
|
|
|
|
return myRestParameter;
|
|
|
|
>myRestParameter : number[]
|
|
|
|
}
|
|
|
|
var withRestParamsVar = withRestParams;
|
2014-08-28 21:52:44 +02:00
|
|
|
>withRestParamsVar : (a: string, ...myRestParameter: number[]) => number[]
|
|
|
|
>withRestParams : (a: string, ...myRestParameter: number[]) => number[]
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
function overload1(n: number) : string;
|
2014-08-28 21:52:44 +02:00
|
|
|
>overload1 : { (n: number): string; (s: string): string; }
|
2014-08-15 23:33:16 +02:00
|
|
|
>n : number
|
|
|
|
|
|
|
|
function overload1(s: string) : string;
|
2014-08-28 21:52:44 +02:00
|
|
|
>overload1 : { (n: number): string; (s: string): string; }
|
2014-08-15 23:33:16 +02:00
|
|
|
>s : string
|
|
|
|
|
|
|
|
function overload1(ns: any) {
|
2014-08-28 21:52:44 +02:00
|
|
|
>overload1 : { (n: number): string; (s: string): string; }
|
2014-08-15 23:33:16 +02:00
|
|
|
>ns : any
|
|
|
|
|
|
|
|
return ns.toString();
|
|
|
|
>ns.toString() : any
|
|
|
|
>ns.toString : any
|
|
|
|
>ns : any
|
|
|
|
>toString : any
|
|
|
|
}
|
|
|
|
var withOverloadSignature = overload1;
|
2014-08-28 21:52:44 +02:00
|
|
|
>withOverloadSignature : { (n: number): string; (s: string): string; }
|
|
|
|
>overload1 : { (n: number): string; (s: string): string; }
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
function f(n: () => void) { }
|
2014-08-28 21:52:44 +02:00
|
|
|
>f : (n: () => void) => void
|
2014-08-15 23:33:16 +02:00
|
|
|
>n : () => void
|
|
|
|
|
|
|
|
module m2 {
|
2014-08-28 21:40:58 +02:00
|
|
|
>m2 : typeof m2
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
export function foo(n: () => void ) {
|
2014-08-28 21:52:44 +02:00
|
|
|
>foo : (n: () => void) => void
|
2014-08-15 23:33:16 +02:00
|
|
|
>n : () => void
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
m2.foo(() => {
|
2014-08-22 03:39:46 +02:00
|
|
|
>m2.foo(() => { var b = 30; return b;}) : void
|
2014-08-28 21:52:44 +02:00
|
|
|
>m2.foo : (n: () => void) => void
|
2014-08-15 23:33:16 +02:00
|
|
|
>m2 : typeof m2
|
2014-08-28 21:52:44 +02:00
|
|
|
>foo : (n: () => void) => void
|
2014-08-22 03:39:46 +02:00
|
|
|
>() => { var b = 30; return b;} : () => number
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
var b = 30;
|
|
|
|
>b : number
|
|
|
|
|
|
|
|
return b;
|
|
|
|
>b : number
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
declare function fooAmbient(n: number): string;
|
2014-08-28 21:52:44 +02:00
|
|
|
>fooAmbient : (n: number) => string
|
2014-08-15 23:33:16 +02:00
|
|
|
>n : number
|
|
|
|
|
|
|
|
declare function overloadAmbient(n: number): string;
|
2014-08-28 21:52:44 +02:00
|
|
|
>overloadAmbient : { (n: number): string; (s: string): string; }
|
2014-08-15 23:33:16 +02:00
|
|
|
>n : number
|
|
|
|
|
|
|
|
declare function overloadAmbient(s: string): string;
|
2014-08-28 21:52:44 +02:00
|
|
|
>overloadAmbient : { (n: number): string; (s: string): string; }
|
2014-08-15 23:33:16 +02:00
|
|
|
>s : string
|
|
|
|
|
|
|
|
var f2 = () => {
|
|
|
|
>f2 : () => string
|
2014-08-22 03:39:46 +02:00
|
|
|
>() => { return "string";} : () => string
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
return "string";
|
|
|
|
}
|