1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
=== tests/cases/compiler/reachabilityChecks7.ts ===
// async function without return type annotation - error
async function f1() {
>f1 : () => Promise<void>
}
let x = async function() {
>x : () => Promise<void>
>async function() {} : () => Promise<void>
}
// async function with which promised type is void - return can be omitted
async function f2(): Promise<void> {
>f2 : () => Promise<void>
}
async function f3(x) {
>f3 : (x: any) => Promise<number>
>x : any
if (x) return 10;
>x : any
>10 : 10
}
async function f4(): Promise<number> {
>f4 : () => Promise<number>
}
function voidFunc(): void {
>voidFunc : () => void
}
function calltoVoidFunc(x) {
>calltoVoidFunc : (x: any) => void
>x : any
if (x) return voidFunc();
>x : any
>voidFunc() : void
>voidFunc : () => void
}
declare function use(s: string): void;
>use : (s: string) => void
>s : string
let x1 = () => { use("Test"); }
>x1 : () => void
>() => { use("Test"); } : () => void
>use("Test") : void
>use : (s: string) => void
>"Test" : "Test"
|