Skip to content

Commit 464d1a7

Browse files
committed
Accept new baselines
1 parent 42500d0 commit 464d1a7

File tree

4 files changed

+746
-1
lines changed

4 files changed

+746
-1
lines changed

tests/baselines/reference/controlFlowOptionalChain.errors.txt

Lines changed: 87 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,12 @@ tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts(112,1): error TS
1919
tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts(130,5): error TS2532: Object is possibly 'undefined'.
2020
tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts(134,1): error TS2532: Object is possibly 'undefined'.
2121
tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts(153,9): error TS2775: Assertions require every name in the call target to be declared with an explicit type annotation.
22+
tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts(197,9): error TS2532: Object is possibly 'undefined'.
23+
tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts(201,9): error TS2532: Object is possibly 'undefined'.
24+
tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts(205,9): error TS2532: Object is possibly 'undefined'.
2225

2326

24-
==== tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts (21 errors) ====
27+
==== tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts (24 errors) ====
2528
// assignments in shortcutting chain
2629
declare const o: undefined | {
2730
[key: string]: any;
@@ -224,4 +227,87 @@ tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts(153,9): error TS
224227
x;
225228
}
226229
}
230+
231+
type Thing = { foo: number, bar(): number };
232+
233+
function f10(o: Thing | undefined, value: number) {
234+
if (o?.foo === value) {
235+
o;
236+
o.foo;
237+
}
238+
if (o?.["foo"] === value) {
239+
o;
240+
o["foo"];
241+
}
242+
if (o?.bar() === value) {
243+
o;
244+
o.bar;
245+
}
246+
}
247+
248+
function f11(o: Thing | null, value: number) {
249+
if (o?.foo === value) {
250+
o;
251+
o.foo;
252+
}
253+
if (o?.["foo"] === value) {
254+
o;
255+
o["foo"];
256+
}
257+
if (o?.bar() === value) {
258+
o;
259+
o.bar;
260+
}
261+
}
262+
263+
function f12(o: Thing | undefined, value: number | undefined) {
264+
if (o?.foo === value) {
265+
o;
266+
o.foo; // Error
267+
~
268+
!!! error TS2532: Object is possibly 'undefined'.
269+
}
270+
if (o?.["foo"] === value) {
271+
o;
272+
o["foo"]; // Error
273+
~
274+
!!! error TS2532: Object is possibly 'undefined'.
275+
}
276+
if (o?.bar() === value) {
277+
o;
278+
o.bar; // Error
279+
~
280+
!!! error TS2532: Object is possibly 'undefined'.
281+
}
282+
}
283+
284+
function f13(o: Thing | undefined) {
285+
if (o?.foo !== undefined) {
286+
o;
287+
o.foo;
288+
}
289+
if (o?.["foo"] !== undefined) {
290+
o;
291+
o["foo"];
292+
}
293+
if (o?.bar() !== undefined) {
294+
o;
295+
o.bar;
296+
}
297+
}
298+
299+
function f14(o: Thing | null) {
300+
if (o?.foo !== undefined) {
301+
o;
302+
o.foo;
303+
}
304+
if (o?.["foo"] !== undefined) {
305+
o;
306+
o["foo"];
307+
}
308+
if (o?.bar() !== undefined) {
309+
o;
310+
o.bar;
311+
}
312+
}
227313

tests/baselines/reference/controlFlowOptionalChain.js

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,83 @@ function f01(x: unknown) {
159159
x;
160160
}
161161
}
162+
163+
type Thing = { foo: number, bar(): number };
164+
165+
function f10(o: Thing | undefined, value: number) {
166+
if (o?.foo === value) {
167+
o;
168+
o.foo;
169+
}
170+
if (o?.["foo"] === value) {
171+
o;
172+
o["foo"];
173+
}
174+
if (o?.bar() === value) {
175+
o;
176+
o.bar;
177+
}
178+
}
179+
180+
function f11(o: Thing | null, value: number) {
181+
if (o?.foo === value) {
182+
o;
183+
o.foo;
184+
}
185+
if (o?.["foo"] === value) {
186+
o;
187+
o["foo"];
188+
}
189+
if (o?.bar() === value) {
190+
o;
191+
o.bar;
192+
}
193+
}
194+
195+
function f12(o: Thing | undefined, value: number | undefined) {
196+
if (o?.foo === value) {
197+
o;
198+
o.foo; // Error
199+
}
200+
if (o?.["foo"] === value) {
201+
o;
202+
o["foo"]; // Error
203+
}
204+
if (o?.bar() === value) {
205+
o;
206+
o.bar; // Error
207+
}
208+
}
209+
210+
function f13(o: Thing | undefined) {
211+
if (o?.foo !== undefined) {
212+
o;
213+
o.foo;
214+
}
215+
if (o?.["foo"] !== undefined) {
216+
o;
217+
o["foo"];
218+
}
219+
if (o?.bar() !== undefined) {
220+
o;
221+
o.bar;
222+
}
223+
}
224+
225+
function f14(o: Thing | null) {
226+
if (o?.foo !== undefined) {
227+
o;
228+
o.foo;
229+
}
230+
if (o?.["foo"] !== undefined) {
231+
o;
232+
o["foo"];
233+
}
234+
if (o?.bar() !== undefined) {
235+
o;
236+
o.bar;
237+
}
238+
}
162239

163240

164241
//// [controlFlowOptionalChain.js]
@@ -286,3 +363,78 @@ function f01(x) {
286363
x;
287364
}
288365
}
366+
function f10(o, value) {
367+
var _a, _b, _c;
368+
if (((_a = o) === null || _a === void 0 ? void 0 : _a.foo) === value) {
369+
o;
370+
o.foo;
371+
}
372+
if (((_b = o) === null || _b === void 0 ? void 0 : _b["foo"]) === value) {
373+
o;
374+
o["foo"];
375+
}
376+
if (((_c = o) === null || _c === void 0 ? void 0 : _c.bar()) === value) {
377+
o;
378+
o.bar;
379+
}
380+
}
381+
function f11(o, value) {
382+
var _a, _b, _c;
383+
if (((_a = o) === null || _a === void 0 ? void 0 : _a.foo) === value) {
384+
o;
385+
o.foo;
386+
}
387+
if (((_b = o) === null || _b === void 0 ? void 0 : _b["foo"]) === value) {
388+
o;
389+
o["foo"];
390+
}
391+
if (((_c = o) === null || _c === void 0 ? void 0 : _c.bar()) === value) {
392+
o;
393+
o.bar;
394+
}
395+
}
396+
function f12(o, value) {
397+
var _a, _b, _c;
398+
if (((_a = o) === null || _a === void 0 ? void 0 : _a.foo) === value) {
399+
o;
400+
o.foo; // Error
401+
}
402+
if (((_b = o) === null || _b === void 0 ? void 0 : _b["foo"]) === value) {
403+
o;
404+
o["foo"]; // Error
405+
}
406+
if (((_c = o) === null || _c === void 0 ? void 0 : _c.bar()) === value) {
407+
o;
408+
o.bar; // Error
409+
}
410+
}
411+
function f13(o) {
412+
var _a, _b, _c;
413+
if (((_a = o) === null || _a === void 0 ? void 0 : _a.foo) !== undefined) {
414+
o;
415+
o.foo;
416+
}
417+
if (((_b = o) === null || _b === void 0 ? void 0 : _b["foo"]) !== undefined) {
418+
o;
419+
o["foo"];
420+
}
421+
if (((_c = o) === null || _c === void 0 ? void 0 : _c.bar()) !== undefined) {
422+
o;
423+
o.bar;
424+
}
425+
}
426+
function f14(o) {
427+
var _a, _b, _c;
428+
if (((_a = o) === null || _a === void 0 ? void 0 : _a.foo) !== undefined) {
429+
o;
430+
o.foo;
431+
}
432+
if (((_b = o) === null || _b === void 0 ? void 0 : _b["foo"]) !== undefined) {
433+
o;
434+
o["foo"];
435+
}
436+
if (((_c = o) === null || _c === void 0 ? void 0 : _c.bar()) !== undefined) {
437+
o;
438+
o.bar;
439+
}
440+
}

0 commit comments

Comments
 (0)