File: asyncFunctionDeclaration15_es6.types

package info (click to toggle)
node-typescript 3.3.3333-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 324,548 kB
  • sloc: makefile: 6; sh: 3
file content (90 lines) | stat: -rw-r--r-- 2,336 bytes parent folder | download | duplicates (5)
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
=== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration15_es6.ts ===
declare class Thenable { then(): void; }
>Thenable : Thenable
>then : () => void

declare let a: any;
>a : any

declare let obj: { then: string; };
>obj : { then: string; }
>then : string

declare let thenable: Thenable;
>thenable : Thenable

async function fn1() { } // valid: Promise<void>
>fn1 : () => Promise<void>

async function fn2(): { } { } // error
>fn2 : () => {}

async function fn3(): any { } // error
>fn3 : () => any

async function fn4(): number { } // error
>fn4 : () => number

async function fn5(): PromiseLike<void> { } // error
>fn5 : () => PromiseLike<void>

async function fn6(): Thenable { } // error
>fn6 : () => Thenable

async function fn7() { return; } // valid: Promise<void>
>fn7 : () => Promise<void>

async function fn8() { return 1; } // valid: Promise<number>
>fn8 : () => Promise<number>
>1 : 1

async function fn9() { return null; } // valid: Promise<any>
>fn9 : () => Promise<any>
>null : null

async function fn10() { return undefined; } // valid: Promise<any>
>fn10 : () => Promise<any>
>undefined : undefined

async function fn11() { return a; } // valid: Promise<any>
>fn11 : () => Promise<any>
>a : any

async function fn12() { return obj; } // valid: Promise<{ then: string; }>
>fn12 : () => Promise<{ then: string; }>
>obj : { then: string; }

async function fn13() { return thenable; } // error
>fn13 : () => Promise<any>
>thenable : Thenable

async function fn14() { await 1; } // valid: Promise<void>
>fn14 : () => Promise<void>
>await 1 : 1
>1 : 1

async function fn15() { await null; } // valid: Promise<void>
>fn15 : () => Promise<void>
>await null : null
>null : null

async function fn16() { await undefined; } // valid: Promise<void>
>fn16 : () => Promise<void>
>await undefined : undefined
>undefined : undefined

async function fn17() { await a; } // valid: Promise<void>
>fn17 : () => Promise<void>
>await a : any
>a : any

async function fn18() { await obj; } // valid: Promise<void>
>fn18 : () => Promise<void>
>await obj : { then: string; }
>obj : { then: string; }

async function fn19() { await thenable; } // error
>fn19 : () => Promise<void>
>await thenable : any
>thenable : Thenable