|
| 1 | +=== tests/cases/compiler/truthinessPromiseCoercion.ts === |
| 2 | +declare const p: Promise<number> |
| 3 | +>p : Symbol(p, Decl(truthinessPromiseCoercion.ts, 0, 13)) |
| 4 | +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --)) |
| 5 | + |
| 6 | +declare const p2: null | Promise<number> |
| 7 | +>p2 : Symbol(p2, Decl(truthinessPromiseCoercion.ts, 1, 13)) |
| 8 | +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --)) |
| 9 | + |
| 10 | +async function f() { |
| 11 | +>f : Symbol(f, Decl(truthinessPromiseCoercion.ts, 1, 40)) |
| 12 | + |
| 13 | + if (p) {} // err |
| 14 | +>p : Symbol(p, Decl(truthinessPromiseCoercion.ts, 0, 13)) |
| 15 | + |
| 16 | + if (!!p) {} // no err |
| 17 | +>p : Symbol(p, Decl(truthinessPromiseCoercion.ts, 0, 13)) |
| 18 | + |
| 19 | + if (p2) {} // no err |
| 20 | +>p2 : Symbol(p2, Decl(truthinessPromiseCoercion.ts, 1, 13)) |
| 21 | + |
| 22 | + p ? f.arguments : f.arguments; |
| 23 | +>p : Symbol(p, Decl(truthinessPromiseCoercion.ts, 0, 13)) |
| 24 | +>f.arguments : Symbol(Function.arguments, Decl(lib.es5.d.ts, --, --)) |
| 25 | +>f : Symbol(f, Decl(truthinessPromiseCoercion.ts, 1, 40)) |
| 26 | +>arguments : Symbol(Function.arguments, Decl(lib.es5.d.ts, --, --)) |
| 27 | +>f.arguments : Symbol(Function.arguments, Decl(lib.es5.d.ts, --, --)) |
| 28 | +>f : Symbol(f, Decl(truthinessPromiseCoercion.ts, 1, 40)) |
| 29 | +>arguments : Symbol(Function.arguments, Decl(lib.es5.d.ts, --, --)) |
| 30 | + |
| 31 | + !!p ? f.arguments : f.arguments; |
| 32 | +>p : Symbol(p, Decl(truthinessPromiseCoercion.ts, 0, 13)) |
| 33 | +>f.arguments : Symbol(Function.arguments, Decl(lib.es5.d.ts, --, --)) |
| 34 | +>f : Symbol(f, Decl(truthinessPromiseCoercion.ts, 1, 40)) |
| 35 | +>arguments : Symbol(Function.arguments, Decl(lib.es5.d.ts, --, --)) |
| 36 | +>f.arguments : Symbol(Function.arguments, Decl(lib.es5.d.ts, --, --)) |
| 37 | +>f : Symbol(f, Decl(truthinessPromiseCoercion.ts, 1, 40)) |
| 38 | +>arguments : Symbol(Function.arguments, Decl(lib.es5.d.ts, --, --)) |
| 39 | + |
| 40 | + p2 ? f.arguments : f.arguments; |
| 41 | +>p2 : Symbol(p2, Decl(truthinessPromiseCoercion.ts, 1, 13)) |
| 42 | +>f.arguments : Symbol(Function.arguments, Decl(lib.es5.d.ts, --, --)) |
| 43 | +>f : Symbol(f, Decl(truthinessPromiseCoercion.ts, 1, 40)) |
| 44 | +>arguments : Symbol(Function.arguments, Decl(lib.es5.d.ts, --, --)) |
| 45 | +>f.arguments : Symbol(Function.arguments, Decl(lib.es5.d.ts, --, --)) |
| 46 | +>f : Symbol(f, Decl(truthinessPromiseCoercion.ts, 1, 40)) |
| 47 | +>arguments : Symbol(Function.arguments, Decl(lib.es5.d.ts, --, --)) |
| 48 | +} |
| 49 | + |
0 commit comments