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
|
=== tests/cases/conformance/expressions/nullishCoalescingOperator/nullishCoalescingOperator7.ts ===
declare const a: string | undefined;
>a : string | undefined
declare const b: string | undefined;
>b : string | undefined
declare const c: string | undefined;
>c : string | undefined
const foo1 = a ? 1 : 2;
>foo1 : 1 | 2
>a ? 1 : 2 : 1 | 2
>a : string | undefined
>1 : 1
>2 : 2
const foo2 = a ?? 'foo' ? 1 : 2;
>foo2 : 1 | 2
>a ?? 'foo' ? 1 : 2 : 1 | 2
>a ?? 'foo' : string
>a : string | undefined
>'foo' : "foo"
>1 : 1
>2 : 2
const foo3 = a ?? 'foo' ? (b ?? 'bar') : (c ?? 'baz');
>foo3 : string
>a ?? 'foo' ? (b ?? 'bar') : (c ?? 'baz') : string
>a ?? 'foo' : string
>a : string | undefined
>'foo' : "foo"
>(b ?? 'bar') : string
>b ?? 'bar' : string
>b : string | undefined
>'bar' : "bar"
>(c ?? 'baz') : string
>c ?? 'baz' : string
>c : string | undefined
>'baz' : "baz"
function f () {
>f : () => void
const foo4 = a ?? 'foo' ? b ?? 'bar' : c ?? 'baz';
>foo4 : string
>a ?? 'foo' ? b ?? 'bar' : c ?? 'baz' : string
>a ?? 'foo' : string
>a : string | undefined
>'foo' : "foo"
>b ?? 'bar' : string
>b : string | undefined
>'bar' : "bar"
>c ?? 'baz' : string
>c : string | undefined
>'baz' : "baz"
}
|