Skip to content

Commit 99cec3a

Browse files
committed
Accept new baselines
1 parent f885181 commit 99cec3a

File tree

4 files changed

+1194
-213
lines changed

4 files changed

+1194
-213
lines changed

tests/baselines/reference/controlFlowOptionalChain.errors.txt

Lines changed: 140 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,21 @@ 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'.
22+
tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts(208,9): error TS2532: Object is possibly 'undefined'.
23+
tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts(211,9): error TS2532: Object is possibly 'undefined'.
24+
tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts(214,9): error TS2532: Object is possibly 'undefined'.
25+
tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts(217,9): error TS2532: Object is possibly 'undefined'.
26+
tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts(220,9): error TS2532: Object is possibly 'undefined'.
27+
tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts(223,9): error TS2532: Object is possibly 'undefined'.
28+
tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts(238,9): error TS2532: Object is possibly 'undefined'.
29+
tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts(241,9): error TS2532: Object is possibly 'undefined'.
30+
tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts(244,9): error TS2532: Object is possibly 'undefined'.
31+
tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts(271,9): error TS2532: Object is possibly 'undefined'.
32+
tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts(274,9): error TS2532: Object is possibly 'undefined'.
33+
tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts(277,9): error TS2532: Object is possibly 'undefined'.
2534

2635

27-
==== tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts (24 errors) ====
36+
==== tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts (33 errors) ====
2837
// assignments in shortcutting chain
2938
declare const o: undefined | {
3039
[key: string]: any;
@@ -228,53 +237,104 @@ tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts(205,9): error TS
228237
}
229238
}
230239

231-
type Thing = { foo: number, bar(): number };
240+
type Thing = { foo: string | number, bar(): number, baz: object };
232241

233242
function f10(o: Thing | undefined, value: number) {
234243
if (o?.foo === value) {
235-
o;
236244
o.foo;
237245
}
238246
if (o?.["foo"] === value) {
239-
o;
240247
o["foo"];
241248
}
242249
if (o?.bar() === value) {
243-
o;
250+
o.bar;
251+
}
252+
if (o?.foo == value) {
253+
o.foo;
254+
}
255+
if (o?.["foo"] == value) {
256+
o["foo"];
257+
}
258+
if (o?.bar() == value) {
244259
o.bar;
245260
}
246261
}
247262

248263
function f11(o: Thing | null, value: number) {
249264
if (o?.foo === value) {
250-
o;
251265
o.foo;
252266
}
253267
if (o?.["foo"] === value) {
254-
o;
255268
o["foo"];
256269
}
257270
if (o?.bar() === value) {
258-
o;
271+
o.bar;
272+
}
273+
if (o?.foo == value) {
274+
o.foo;
275+
}
276+
if (o?.["foo"] == value) {
277+
o["foo"];
278+
}
279+
if (o?.bar() == value) {
259280
o.bar;
260281
}
261282
}
262283

263284
function f12(o: Thing | undefined, value: number | undefined) {
264285
if (o?.foo === value) {
265-
o;
266286
o.foo; // Error
267287
~
268288
!!! error TS2532: Object is possibly 'undefined'.
269289
}
270290
if (o?.["foo"] === value) {
271-
o;
272291
o["foo"]; // Error
273292
~
274293
!!! error TS2532: Object is possibly 'undefined'.
275294
}
276295
if (o?.bar() === value) {
277-
o;
296+
o.bar; // Error
297+
~
298+
!!! error TS2532: Object is possibly 'undefined'.
299+
}
300+
if (o?.foo == value) {
301+
o.foo; // Error
302+
~
303+
!!! error TS2532: Object is possibly 'undefined'.
304+
}
305+
if (o?.["foo"] == value) {
306+
o["foo"]; // Error
307+
~
308+
!!! error TS2532: Object is possibly 'undefined'.
309+
}
310+
if (o?.bar() == value) {
311+
o.bar; // Error
312+
~
313+
!!! error TS2532: Object is possibly 'undefined'.
314+
}
315+
}
316+
317+
function f12a(o: Thing | undefined, value: number | null) {
318+
if (o?.foo === value) {
319+
o.foo;
320+
}
321+
if (o?.["foo"] === value) {
322+
o["foo"];
323+
}
324+
if (o?.bar() === value) {
325+
o.bar;
326+
}
327+
if (o?.foo == value) {
328+
o.foo; // Error
329+
~
330+
!!! error TS2532: Object is possibly 'undefined'.
331+
}
332+
if (o?.["foo"] == value) {
333+
o["foo"]; // Error
334+
~
335+
!!! error TS2532: Object is possibly 'undefined'.
336+
}
337+
if (o?.bar() == value) {
278338
o.bar; // Error
279339
~
280340
!!! error TS2532: Object is possibly 'undefined'.
@@ -283,31 +343,91 @@ tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts(205,9): error TS
283343

284344
function f13(o: Thing | undefined) {
285345
if (o?.foo !== undefined) {
286-
o;
287346
o.foo;
288347
}
289348
if (o?.["foo"] !== undefined) {
290-
o;
291349
o["foo"];
292350
}
293351
if (o?.bar() !== undefined) {
294-
o;
352+
o.bar;
353+
}
354+
if (o?.foo != undefined) {
355+
o.foo;
356+
}
357+
if (o?.["foo"] != undefined) {
358+
o["foo"];
359+
}
360+
if (o?.bar() != undefined) {
361+
o.bar;
362+
}
363+
}
364+
365+
function f13a(o: Thing | undefined) {
366+
if (o?.foo !== null) {
367+
o.foo; // Error
368+
~
369+
!!! error TS2532: Object is possibly 'undefined'.
370+
}
371+
if (o?.["foo"] !== null) {
372+
o["foo"]; // Error
373+
~
374+
!!! error TS2532: Object is possibly 'undefined'.
375+
}
376+
if (o?.bar() !== null) {
377+
o.bar; // Error
378+
~
379+
!!! error TS2532: Object is possibly 'undefined'.
380+
}
381+
if (o?.foo != null) {
382+
o.foo;
383+
}
384+
if (o?.["foo"] != null) {
385+
o["foo"];
386+
}
387+
if (o?.bar() != null) {
295388
o.bar;
296389
}
297390
}
298391

299392
function f14(o: Thing | null) {
300393
if (o?.foo !== undefined) {
301-
o;
302394
o.foo;
303395
}
304396
if (o?.["foo"] !== undefined) {
305-
o;
306397
o["foo"];
307398
}
308399
if (o?.bar() !== undefined) {
309-
o;
310400
o.bar;
311401
}
312402
}
403+
404+
function f20(o: Thing | undefined) {
405+
if (typeof o?.foo === "number") {
406+
o.foo;
407+
}
408+
if (typeof o?.["foo"] === "number") {
409+
o["foo"];
410+
}
411+
if (typeof o?.bar() === "number") {
412+
o.bar;
413+
}
414+
if (o?.baz instanceof Error) {
415+
o.baz;
416+
}
417+
}
418+
419+
function f21(o: Thing | null) {
420+
if (typeof o?.foo === "number") {
421+
o.foo;
422+
}
423+
if (typeof o?.["foo"] === "number") {
424+
o["foo"];
425+
}
426+
if (typeof o?.bar() === "number") {
427+
o.bar;
428+
}
429+
if (o?.baz instanceof Error) {
430+
o.baz;
431+
}
432+
}
313433

0 commit comments

Comments
 (0)