File: nullishCoalescingOperator1.types

package info (click to toggle)
node-typescript 5.0.4%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 459,140 kB
  • sloc: javascript: 1,972,754; makefile: 6; sh: 1
file content (223 lines) | stat: -rw-r--r-- 4,403 bytes parent folder | download | duplicates (4)
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
=== tests/cases/conformance/expressions/nullishCoalescingOperator/nullishCoalescingOperator1.ts ===
declare const a1: string | undefined | null
>a1 : string | null | undefined
>null : null

declare const a2: string | undefined | null
>a2 : string | null | undefined
>null : null

declare const a3: string | undefined | null
>a3 : string | null | undefined
>null : null

declare const a4: string | undefined | null
>a4 : string | null | undefined
>null : null

declare const b1: number | undefined | null
>b1 : number | null | undefined
>null : null

declare const b2: number | undefined | null
>b2 : number | null | undefined
>null : null

declare const b3: number | undefined | null
>b3 : number | null | undefined
>null : null

declare const b4: number | undefined | null
>b4 : number | null | undefined
>null : null

declare const c1: boolean | undefined | null
>c1 : boolean | null | undefined
>null : null

declare const c2: boolean | undefined | null
>c2 : boolean | null | undefined
>null : null

declare const c3: boolean | undefined | null
>c3 : boolean | null | undefined
>null : null

declare const c4: boolean | undefined | null
>c4 : boolean | null | undefined
>null : null

interface I { a: string }
>a : string

declare const d1: I | undefined | null
>d1 : I | null | undefined
>null : null

declare const d2: I | undefined | null
>d2 : I | null | undefined
>null : null

declare const d3: I | undefined | null
>d3 : I | null | undefined
>null : null

declare const d4: I | undefined | null
>d4 : I | null | undefined
>null : null

const aa1 = a1 ?? 'whatever';
>aa1 : string
>a1 ?? 'whatever' : string
>a1 : string | null | undefined
>'whatever' : "whatever"

const aa2 = a2 ?? 'whatever';
>aa2 : string
>a2 ?? 'whatever' : string
>a2 : string | null | undefined
>'whatever' : "whatever"

const aa3 = a3 ?? 'whatever';
>aa3 : string
>a3 ?? 'whatever' : string
>a3 : string | null | undefined
>'whatever' : "whatever"

const aa4 = a4 ?? 'whatever';
>aa4 : string
>a4 ?? 'whatever' : string
>a4 : string | null | undefined
>'whatever' : "whatever"

const bb1 = b1 ?? 1;
>bb1 : number
>b1 ?? 1 : number
>b1 : number | null | undefined
>1 : 1

const bb2 = b2 ?? 1;
>bb2 : number
>b2 ?? 1 : number
>b2 : number | null | undefined
>1 : 1

const bb3 = b3 ?? 1;
>bb3 : number
>b3 ?? 1 : number
>b3 : number | null | undefined
>1 : 1

const bb4 = b4 ?? 1;
>bb4 : number
>b4 ?? 1 : number
>b4 : number | null | undefined
>1 : 1

const cc1 = c1 ?? true;
>cc1 : boolean
>c1 ?? true : boolean
>c1 : boolean | null | undefined
>true : true

const cc2 = c2 ?? true;
>cc2 : boolean
>c2 ?? true : boolean
>c2 : boolean | null | undefined
>true : true

const cc3 = c3 ?? true;
>cc3 : boolean
>c3 ?? true : boolean
>c3 : boolean | null | undefined
>true : true

const cc4 = c4 ?? true;
>cc4 : boolean
>c4 ?? true : boolean
>c4 : boolean | null | undefined
>true : true

const dd1 = d1 ?? {b: 1};
>dd1 : I | { b: number; }
>d1 ?? {b: 1} : I | { b: number; }
>d1 : I | null | undefined
>{b: 1} : { b: number; }
>b : number
>1 : 1

const dd2 = d2 ?? {b: 1};
>dd2 : I | { b: number; }
>d2 ?? {b: 1} : I | { b: number; }
>d2 : I | null | undefined
>{b: 1} : { b: number; }
>b : number
>1 : 1

const dd3 = d3 ?? {b: 1};
>dd3 : I | { b: number; }
>d3 ?? {b: 1} : I | { b: number; }
>d3 : I | null | undefined
>{b: 1} : { b: number; }
>b : number
>1 : 1

const dd4 = d4 ?? {b: 1};
>dd4 : I | { b: number; }
>d4 ?? {b: 1} : I | { b: number; }
>d4 : I | null | undefined
>{b: 1} : { b: number; }
>b : number
>1 : 1

// Repro from #34635

declare function foo(): void;
>foo : () => void

const maybeBool = false;
>maybeBool : false
>false : false

if (!(maybeBool ?? true)) {
>!(maybeBool ?? true) : true
>(maybeBool ?? true) : false
>maybeBool ?? true : false
>maybeBool : false
>true : true

    foo();
>foo() : void
>foo : () => void
}

if (maybeBool ?? true) {
>maybeBool ?? true : false
>maybeBool : false
>true : true

    foo();
>foo() : void
>foo : () => void
}
else {
    foo();
>foo() : void
>foo : () => void
}

if (false ?? true) {
>false ?? true : false
>false : false
>true : true

    foo();
>foo() : void
>foo : () => void
}
else {
    foo();
>foo() : void
>foo : () => void
}