From 99cec3a0d6875f842c666f8021228e069beab2d6 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sat, 5 Oct 2019 13:08:39 -0700 Subject: [PATCH] Accept new baselines --- .../controlFlowOptionalChain.errors.txt | 160 +++++- .../reference/controlFlowOptionalChain.js | 256 +++++++-- .../controlFlowOptionalChain.symbols | 502 +++++++++++++---- .../reference/controlFlowOptionalChain.types | 503 +++++++++++++++--- 4 files changed, 1201 insertions(+), 220 deletions(-) diff --git a/tests/baselines/reference/controlFlowOptionalChain.errors.txt b/tests/baselines/reference/controlFlowOptionalChain.errors.txt index 1c5c4b18399..987dca335dc 100644 --- a/tests/baselines/reference/controlFlowOptionalChain.errors.txt +++ b/tests/baselines/reference/controlFlowOptionalChain.errors.txt @@ -19,12 +19,21 @@ tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts(112,1): error TS tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts(130,5): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts(134,1): error TS2532: Object is possibly 'undefined'. 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. -tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts(197,9): error TS2532: Object is possibly 'undefined'. -tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts(201,9): error TS2532: Object is possibly 'undefined'. -tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts(205,9): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts(208,9): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts(211,9): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts(214,9): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts(217,9): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts(220,9): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts(223,9): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts(238,9): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts(241,9): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts(244,9): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts(271,9): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts(274,9): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts(277,9): error TS2532: Object is possibly 'undefined'. -==== tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts (24 errors) ==== +==== tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts (33 errors) ==== // assignments in shortcutting chain declare const o: undefined | { [key: string]: any; @@ -228,53 +237,104 @@ tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts(205,9): error TS } } - type Thing = { foo: number, bar(): number }; + type Thing = { foo: string | number, bar(): number, baz: object }; function f10(o: Thing | undefined, value: number) { if (o?.foo === value) { - o; o.foo; } if (o?.["foo"] === value) { - o; o["foo"]; } if (o?.bar() === value) { - o; + o.bar; + } + if (o?.foo == value) { + o.foo; + } + if (o?.["foo"] == value) { + o["foo"]; + } + if (o?.bar() == value) { o.bar; } } function f11(o: Thing | null, value: number) { if (o?.foo === value) { - o; o.foo; } if (o?.["foo"] === value) { - o; o["foo"]; } if (o?.bar() === value) { - o; + o.bar; + } + if (o?.foo == value) { + o.foo; + } + if (o?.["foo"] == value) { + o["foo"]; + } + if (o?.bar() == value) { o.bar; } } function f12(o: Thing | undefined, value: number | undefined) { if (o?.foo === value) { - o; o.foo; // Error ~ !!! error TS2532: Object is possibly 'undefined'. } if (o?.["foo"] === value) { - o; o["foo"]; // Error ~ !!! error TS2532: Object is possibly 'undefined'. } if (o?.bar() === value) { - o; + o.bar; // Error + ~ +!!! error TS2532: Object is possibly 'undefined'. + } + if (o?.foo == value) { + o.foo; // Error + ~ +!!! error TS2532: Object is possibly 'undefined'. + } + if (o?.["foo"] == value) { + o["foo"]; // Error + ~ +!!! error TS2532: Object is possibly 'undefined'. + } + if (o?.bar() == value) { + o.bar; // Error + ~ +!!! error TS2532: Object is possibly 'undefined'. + } + } + + function f12a(o: Thing | undefined, value: number | null) { + if (o?.foo === value) { + o.foo; + } + if (o?.["foo"] === value) { + o["foo"]; + } + if (o?.bar() === value) { + o.bar; + } + if (o?.foo == value) { + o.foo; // Error + ~ +!!! error TS2532: Object is possibly 'undefined'. + } + if (o?.["foo"] == value) { + o["foo"]; // Error + ~ +!!! error TS2532: Object is possibly 'undefined'. + } + if (o?.bar() == value) { o.bar; // Error ~ !!! error TS2532: Object is possibly 'undefined'. @@ -283,31 +343,91 @@ tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts(205,9): error TS function f13(o: Thing | undefined) { if (o?.foo !== undefined) { - o; o.foo; } if (o?.["foo"] !== undefined) { - o; o["foo"]; } if (o?.bar() !== undefined) { - o; + o.bar; + } + if (o?.foo != undefined) { + o.foo; + } + if (o?.["foo"] != undefined) { + o["foo"]; + } + if (o?.bar() != undefined) { + o.bar; + } + } + + function f13a(o: Thing | undefined) { + if (o?.foo !== null) { + o.foo; // Error + ~ +!!! error TS2532: Object is possibly 'undefined'. + } + if (o?.["foo"] !== null) { + o["foo"]; // Error + ~ +!!! error TS2532: Object is possibly 'undefined'. + } + if (o?.bar() !== null) { + o.bar; // Error + ~ +!!! error TS2532: Object is possibly 'undefined'. + } + if (o?.foo != null) { + o.foo; + } + if (o?.["foo"] != null) { + o["foo"]; + } + if (o?.bar() != null) { o.bar; } } function f14(o: Thing | null) { if (o?.foo !== undefined) { - o; o.foo; } if (o?.["foo"] !== undefined) { - o; o["foo"]; } if (o?.bar() !== undefined) { - o; o.bar; } } + + function f20(o: Thing | undefined) { + if (typeof o?.foo === "number") { + o.foo; + } + if (typeof o?.["foo"] === "number") { + o["foo"]; + } + if (typeof o?.bar() === "number") { + o.bar; + } + if (o?.baz instanceof Error) { + o.baz; + } + } + + function f21(o: Thing | null) { + if (typeof o?.foo === "number") { + o.foo; + } + if (typeof o?.["foo"] === "number") { + o["foo"]; + } + if (typeof o?.bar() === "number") { + o.bar; + } + if (o?.baz instanceof Error) { + o.baz; + } + } \ No newline at end of file diff --git a/tests/baselines/reference/controlFlowOptionalChain.js b/tests/baselines/reference/controlFlowOptionalChain.js index 9b42d764726..21451528035 100644 --- a/tests/baselines/reference/controlFlowOptionalChain.js +++ b/tests/baselines/reference/controlFlowOptionalChain.js @@ -160,82 +160,175 @@ function f01(x: unknown) { } } -type Thing = { foo: number, bar(): number }; +type Thing = { foo: string | number, bar(): number, baz: object }; function f10(o: Thing | undefined, value: number) { if (o?.foo === value) { - o; o.foo; } if (o?.["foo"] === value) { - o; o["foo"]; } if (o?.bar() === value) { - o; + o.bar; + } + if (o?.foo == value) { + o.foo; + } + if (o?.["foo"] == value) { + o["foo"]; + } + if (o?.bar() == value) { o.bar; } } function f11(o: Thing | null, value: number) { if (o?.foo === value) { - o; o.foo; } if (o?.["foo"] === value) { - o; o["foo"]; } if (o?.bar() === value) { - o; + o.bar; + } + if (o?.foo == value) { + o.foo; + } + if (o?.["foo"] == value) { + o["foo"]; + } + if (o?.bar() == value) { o.bar; } } function f12(o: Thing | undefined, value: number | undefined) { if (o?.foo === value) { - o; o.foo; // Error } if (o?.["foo"] === value) { - o; o["foo"]; // Error } if (o?.bar() === value) { - o; + o.bar; // Error + } + if (o?.foo == value) { + o.foo; // Error + } + if (o?.["foo"] == value) { + o["foo"]; // Error + } + if (o?.bar() == value) { + o.bar; // Error + } +} + +function f12a(o: Thing | undefined, value: number | null) { + if (o?.foo === value) { + o.foo; + } + if (o?.["foo"] === value) { + o["foo"]; + } + if (o?.bar() === value) { + o.bar; + } + if (o?.foo == value) { + o.foo; // Error + } + if (o?.["foo"] == value) { + o["foo"]; // Error + } + if (o?.bar() == value) { o.bar; // Error } } function f13(o: Thing | undefined) { if (o?.foo !== undefined) { - o; o.foo; } if (o?.["foo"] !== undefined) { - o; o["foo"]; } if (o?.bar() !== undefined) { - o; + o.bar; + } + if (o?.foo != undefined) { + o.foo; + } + if (o?.["foo"] != undefined) { + o["foo"]; + } + if (o?.bar() != undefined) { + o.bar; + } +} + +function f13a(o: Thing | undefined) { + if (o?.foo !== null) { + o.foo; // Error + } + if (o?.["foo"] !== null) { + o["foo"]; // Error + } + if (o?.bar() !== null) { + o.bar; // Error + } + if (o?.foo != null) { + o.foo; + } + if (o?.["foo"] != null) { + o["foo"]; + } + if (o?.bar() != null) { o.bar; } } function f14(o: Thing | null) { if (o?.foo !== undefined) { - o; o.foo; } if (o?.["foo"] !== undefined) { - o; o["foo"]; } if (o?.bar() !== undefined) { - o; o.bar; } } + +function f20(o: Thing | undefined) { + if (typeof o?.foo === "number") { + o.foo; + } + if (typeof o?.["foo"] === "number") { + o["foo"]; + } + if (typeof o?.bar() === "number") { + o.bar; + } + if (o?.baz instanceof Error) { + o.baz; + } +} + +function f21(o: Thing | null) { + if (typeof o?.foo === "number") { + o.foo; + } + if (typeof o?.["foo"] === "number") { + o["foo"]; + } + if (typeof o?.bar() === "number") { + o.bar; + } + if (o?.baz instanceof Error) { + o.baz; + } +} //// [controlFlowOptionalChain.js] @@ -364,77 +457,170 @@ function f01(x) { } } function f10(o, value) { - var _a, _b, _c; + var _a, _b, _c, _d, _e, _f; if (((_a = o) === null || _a === void 0 ? void 0 : _a.foo) === value) { - o; o.foo; } if (((_b = o) === null || _b === void 0 ? void 0 : _b["foo"]) === value) { - o; o["foo"]; } if (((_c = o) === null || _c === void 0 ? void 0 : _c.bar()) === value) { - o; + o.bar; + } + if (((_d = o) === null || _d === void 0 ? void 0 : _d.foo) == value) { + o.foo; + } + if (((_e = o) === null || _e === void 0 ? void 0 : _e["foo"]) == value) { + o["foo"]; + } + if (((_f = o) === null || _f === void 0 ? void 0 : _f.bar()) == value) { o.bar; } } function f11(o, value) { - var _a, _b, _c; + var _a, _b, _c, _d, _e, _f; if (((_a = o) === null || _a === void 0 ? void 0 : _a.foo) === value) { - o; o.foo; } if (((_b = o) === null || _b === void 0 ? void 0 : _b["foo"]) === value) { - o; o["foo"]; } if (((_c = o) === null || _c === void 0 ? void 0 : _c.bar()) === value) { - o; + o.bar; + } + if (((_d = o) === null || _d === void 0 ? void 0 : _d.foo) == value) { + o.foo; + } + if (((_e = o) === null || _e === void 0 ? void 0 : _e["foo"]) == value) { + o["foo"]; + } + if (((_f = o) === null || _f === void 0 ? void 0 : _f.bar()) == value) { o.bar; } } function f12(o, value) { - var _a, _b, _c; + var _a, _b, _c, _d, _e, _f; if (((_a = o) === null || _a === void 0 ? void 0 : _a.foo) === value) { - o; o.foo; // Error } if (((_b = o) === null || _b === void 0 ? void 0 : _b["foo"]) === value) { - o; o["foo"]; // Error } if (((_c = o) === null || _c === void 0 ? void 0 : _c.bar()) === value) { - o; + o.bar; // Error + } + if (((_d = o) === null || _d === void 0 ? void 0 : _d.foo) == value) { + o.foo; // Error + } + if (((_e = o) === null || _e === void 0 ? void 0 : _e["foo"]) == value) { + o["foo"]; // Error + } + if (((_f = o) === null || _f === void 0 ? void 0 : _f.bar()) == value) { + o.bar; // Error + } +} +function f12a(o, value) { + var _a, _b, _c, _d, _e, _f; + if (((_a = o) === null || _a === void 0 ? void 0 : _a.foo) === value) { + o.foo; + } + if (((_b = o) === null || _b === void 0 ? void 0 : _b["foo"]) === value) { + o["foo"]; + } + if (((_c = o) === null || _c === void 0 ? void 0 : _c.bar()) === value) { + o.bar; + } + if (((_d = o) === null || _d === void 0 ? void 0 : _d.foo) == value) { + o.foo; // Error + } + if (((_e = o) === null || _e === void 0 ? void 0 : _e["foo"]) == value) { + o["foo"]; // Error + } + if (((_f = o) === null || _f === void 0 ? void 0 : _f.bar()) == value) { o.bar; // Error } } function f13(o) { - var _a, _b, _c; + var _a, _b, _c, _d, _e, _f; if (((_a = o) === null || _a === void 0 ? void 0 : _a.foo) !== undefined) { - o; o.foo; } if (((_b = o) === null || _b === void 0 ? void 0 : _b["foo"]) !== undefined) { - o; o["foo"]; } if (((_c = o) === null || _c === void 0 ? void 0 : _c.bar()) !== undefined) { - o; + o.bar; + } + if (((_d = o) === null || _d === void 0 ? void 0 : _d.foo) != undefined) { + o.foo; + } + if (((_e = o) === null || _e === void 0 ? void 0 : _e["foo"]) != undefined) { + o["foo"]; + } + if (((_f = o) === null || _f === void 0 ? void 0 : _f.bar()) != undefined) { + o.bar; + } +} +function f13a(o) { + var _a, _b, _c, _d, _e, _f; + if (((_a = o) === null || _a === void 0 ? void 0 : _a.foo) !== null) { + o.foo; // Error + } + if (((_b = o) === null || _b === void 0 ? void 0 : _b["foo"]) !== null) { + o["foo"]; // Error + } + if (((_c = o) === null || _c === void 0 ? void 0 : _c.bar()) !== null) { + o.bar; // Error + } + if (((_d = o) === null || _d === void 0 ? void 0 : _d.foo) != null) { + o.foo; + } + if (((_e = o) === null || _e === void 0 ? void 0 : _e["foo"]) != null) { + o["foo"]; + } + if (((_f = o) === null || _f === void 0 ? void 0 : _f.bar()) != null) { o.bar; } } function f14(o) { var _a, _b, _c; if (((_a = o) === null || _a === void 0 ? void 0 : _a.foo) !== undefined) { - o; o.foo; } if (((_b = o) === null || _b === void 0 ? void 0 : _b["foo"]) !== undefined) { - o; o["foo"]; } if (((_c = o) === null || _c === void 0 ? void 0 : _c.bar()) !== undefined) { - o; o.bar; } } +function f20(o) { + var _a, _b, _c, _d; + if (typeof ((_a = o) === null || _a === void 0 ? void 0 : _a.foo) === "number") { + o.foo; + } + if (typeof ((_b = o) === null || _b === void 0 ? void 0 : _b["foo"]) === "number") { + o["foo"]; + } + if (typeof ((_c = o) === null || _c === void 0 ? void 0 : _c.bar()) === "number") { + o.bar; + } + if (((_d = o) === null || _d === void 0 ? void 0 : _d.baz) instanceof Error) { + o.baz; + } +} +function f21(o) { + var _a, _b, _c, _d; + if (typeof ((_a = o) === null || _a === void 0 ? void 0 : _a.foo) === "number") { + o.foo; + } + if (typeof ((_b = o) === null || _b === void 0 ? void 0 : _b["foo"]) === "number") { + o["foo"]; + } + if (typeof ((_c = o) === null || _c === void 0 ? void 0 : _c.bar()) === "number") { + o.bar; + } + if (((_d = o) === null || _d === void 0 ? void 0 : _d.baz) instanceof Error) { + o.baz; + } +} diff --git a/tests/baselines/reference/controlFlowOptionalChain.symbols b/tests/baselines/reference/controlFlowOptionalChain.symbols index 495e6371a63..2665a960a56 100644 --- a/tests/baselines/reference/controlFlowOptionalChain.symbols +++ b/tests/baselines/reference/controlFlowOptionalChain.symbols @@ -600,13 +600,14 @@ function f01(x: unknown) { } } -type Thing = { foo: number, bar(): number }; +type Thing = { foo: string | number, bar(): number, baz: object }; >Thing : Symbol(Thing, Decl(controlFlowOptionalChain.ts, 159, 1)) >foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) ->bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 27)) +>bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 36)) +>baz : Symbol(baz, Decl(controlFlowOptionalChain.ts, 161, 51)) function f10(o: Thing | undefined, value: number) { ->f10 : Symbol(f10, Decl(controlFlowOptionalChain.ts, 161, 44)) +>f10 : Symbol(f10, Decl(controlFlowOptionalChain.ts, 161, 66)) >o : Symbol(o, Decl(controlFlowOptionalChain.ts, 163, 13)) >Thing : Symbol(Thing, Decl(controlFlowOptionalChain.ts, 159, 1)) >value : Symbol(value, Decl(controlFlowOptionalChain.ts, 163, 34)) @@ -617,9 +618,6 @@ function f10(o: Thing | undefined, value: number) { >foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) >value : Symbol(value, Decl(controlFlowOptionalChain.ts, 163, 34)) - o; ->o : Symbol(o, Decl(controlFlowOptionalChain.ts, 163, 13)) - o.foo; >o.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) >o : Symbol(o, Decl(controlFlowOptionalChain.ts, 163, 13)) @@ -629,211 +627,505 @@ function f10(o: Thing | undefined, value: number) { >o : Symbol(o, Decl(controlFlowOptionalChain.ts, 163, 13)) >value : Symbol(value, Decl(controlFlowOptionalChain.ts, 163, 34)) - o; ->o : Symbol(o, Decl(controlFlowOptionalChain.ts, 163, 13)) - o["foo"]; >o : Symbol(o, Decl(controlFlowOptionalChain.ts, 163, 13)) >"foo" : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) } if (o?.bar() === value) { ->o?.bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 27)) +>o?.bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 36)) >o : Symbol(o, Decl(controlFlowOptionalChain.ts, 163, 13)) ->bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 27)) +>bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 36)) >value : Symbol(value, Decl(controlFlowOptionalChain.ts, 163, 34)) - o; + o.bar; +>o.bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 36)) >o : Symbol(o, Decl(controlFlowOptionalChain.ts, 163, 13)) +>bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 36)) + } + if (o?.foo == value) { +>o?.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 163, 13)) +>foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>value : Symbol(value, Decl(controlFlowOptionalChain.ts, 163, 34)) + + o.foo; +>o.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 163, 13)) +>foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) + } + if (o?.["foo"] == value) { +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 163, 13)) +>value : Symbol(value, Decl(controlFlowOptionalChain.ts, 163, 34)) + + o["foo"]; +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 163, 13)) +>"foo" : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) + } + if (o?.bar() == value) { +>o?.bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 36)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 163, 13)) +>bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 36)) +>value : Symbol(value, Decl(controlFlowOptionalChain.ts, 163, 34)) o.bar; ->o.bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 27)) +>o.bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 36)) >o : Symbol(o, Decl(controlFlowOptionalChain.ts, 163, 13)) ->bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 27)) +>bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 36)) } } function f11(o: Thing | null, value: number) { ->f11 : Symbol(f11, Decl(controlFlowOptionalChain.ts, 176, 1)) ->o : Symbol(o, Decl(controlFlowOptionalChain.ts, 178, 13)) +>f11 : Symbol(f11, Decl(controlFlowOptionalChain.ts, 182, 1)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 184, 13)) >Thing : Symbol(Thing, Decl(controlFlowOptionalChain.ts, 159, 1)) ->value : Symbol(value, Decl(controlFlowOptionalChain.ts, 178, 29)) +>value : Symbol(value, Decl(controlFlowOptionalChain.ts, 184, 29)) if (o?.foo === value) { >o?.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) ->o : Symbol(o, Decl(controlFlowOptionalChain.ts, 178, 13)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 184, 13)) >foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) ->value : Symbol(value, Decl(controlFlowOptionalChain.ts, 178, 29)) - - o; ->o : Symbol(o, Decl(controlFlowOptionalChain.ts, 178, 13)) +>value : Symbol(value, Decl(controlFlowOptionalChain.ts, 184, 29)) o.foo; >o.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) ->o : Symbol(o, Decl(controlFlowOptionalChain.ts, 178, 13)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 184, 13)) >foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) } if (o?.["foo"] === value) { ->o : Symbol(o, Decl(controlFlowOptionalChain.ts, 178, 13)) ->value : Symbol(value, Decl(controlFlowOptionalChain.ts, 178, 29)) - - o; ->o : Symbol(o, Decl(controlFlowOptionalChain.ts, 178, 13)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 184, 13)) +>value : Symbol(value, Decl(controlFlowOptionalChain.ts, 184, 29)) o["foo"]; ->o : Symbol(o, Decl(controlFlowOptionalChain.ts, 178, 13)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 184, 13)) >"foo" : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) } if (o?.bar() === value) { ->o?.bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 27)) ->o : Symbol(o, Decl(controlFlowOptionalChain.ts, 178, 13)) ->bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 27)) ->value : Symbol(value, Decl(controlFlowOptionalChain.ts, 178, 29)) - - o; ->o : Symbol(o, Decl(controlFlowOptionalChain.ts, 178, 13)) +>o?.bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 36)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 184, 13)) +>bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 36)) +>value : Symbol(value, Decl(controlFlowOptionalChain.ts, 184, 29)) o.bar; ->o.bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 27)) ->o : Symbol(o, Decl(controlFlowOptionalChain.ts, 178, 13)) ->bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 27)) +>o.bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 36)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 184, 13)) +>bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 36)) + } + if (o?.foo == value) { +>o?.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 184, 13)) +>foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>value : Symbol(value, Decl(controlFlowOptionalChain.ts, 184, 29)) + + o.foo; +>o.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 184, 13)) +>foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) + } + if (o?.["foo"] == value) { +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 184, 13)) +>value : Symbol(value, Decl(controlFlowOptionalChain.ts, 184, 29)) + + o["foo"]; +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 184, 13)) +>"foo" : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) + } + if (o?.bar() == value) { +>o?.bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 36)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 184, 13)) +>bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 36)) +>value : Symbol(value, Decl(controlFlowOptionalChain.ts, 184, 29)) + + o.bar; +>o.bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 36)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 184, 13)) +>bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 36)) } } function f12(o: Thing | undefined, value: number | undefined) { ->f12 : Symbol(f12, Decl(controlFlowOptionalChain.ts, 191, 1)) ->o : Symbol(o, Decl(controlFlowOptionalChain.ts, 193, 13)) +>f12 : Symbol(f12, Decl(controlFlowOptionalChain.ts, 203, 1)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 205, 13)) >Thing : Symbol(Thing, Decl(controlFlowOptionalChain.ts, 159, 1)) ->value : Symbol(value, Decl(controlFlowOptionalChain.ts, 193, 34)) +>value : Symbol(value, Decl(controlFlowOptionalChain.ts, 205, 34)) if (o?.foo === value) { >o?.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) ->o : Symbol(o, Decl(controlFlowOptionalChain.ts, 193, 13)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 205, 13)) >foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) ->value : Symbol(value, Decl(controlFlowOptionalChain.ts, 193, 34)) - - o; ->o : Symbol(o, Decl(controlFlowOptionalChain.ts, 193, 13)) +>value : Symbol(value, Decl(controlFlowOptionalChain.ts, 205, 34)) o.foo; // Error >o.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) ->o : Symbol(o, Decl(controlFlowOptionalChain.ts, 193, 13)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 205, 13)) >foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) } if (o?.["foo"] === value) { ->o : Symbol(o, Decl(controlFlowOptionalChain.ts, 193, 13)) ->value : Symbol(value, Decl(controlFlowOptionalChain.ts, 193, 34)) - - o; ->o : Symbol(o, Decl(controlFlowOptionalChain.ts, 193, 13)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 205, 13)) +>value : Symbol(value, Decl(controlFlowOptionalChain.ts, 205, 34)) o["foo"]; // Error ->o : Symbol(o, Decl(controlFlowOptionalChain.ts, 193, 13)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 205, 13)) } if (o?.bar() === value) { ->o?.bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 27)) ->o : Symbol(o, Decl(controlFlowOptionalChain.ts, 193, 13)) ->bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 27)) ->value : Symbol(value, Decl(controlFlowOptionalChain.ts, 193, 34)) - - o; ->o : Symbol(o, Decl(controlFlowOptionalChain.ts, 193, 13)) +>o?.bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 36)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 205, 13)) +>bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 36)) +>value : Symbol(value, Decl(controlFlowOptionalChain.ts, 205, 34)) o.bar; // Error ->o.bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 27)) ->o : Symbol(o, Decl(controlFlowOptionalChain.ts, 193, 13)) ->bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 27)) +>o.bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 36)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 205, 13)) +>bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 36)) + } + if (o?.foo == value) { +>o?.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 205, 13)) +>foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>value : Symbol(value, Decl(controlFlowOptionalChain.ts, 205, 34)) + + o.foo; // Error +>o.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 205, 13)) +>foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) + } + if (o?.["foo"] == value) { +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 205, 13)) +>value : Symbol(value, Decl(controlFlowOptionalChain.ts, 205, 34)) + + o["foo"]; // Error +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 205, 13)) + } + if (o?.bar() == value) { +>o?.bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 36)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 205, 13)) +>bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 36)) +>value : Symbol(value, Decl(controlFlowOptionalChain.ts, 205, 34)) + + o.bar; // Error +>o.bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 36)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 205, 13)) +>bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 36)) + } +} + +function f12a(o: Thing | undefined, value: number | null) { +>f12a : Symbol(f12a, Decl(controlFlowOptionalChain.ts, 224, 1)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 226, 14)) +>Thing : Symbol(Thing, Decl(controlFlowOptionalChain.ts, 159, 1)) +>value : Symbol(value, Decl(controlFlowOptionalChain.ts, 226, 35)) + + if (o?.foo === value) { +>o?.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 226, 14)) +>foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>value : Symbol(value, Decl(controlFlowOptionalChain.ts, 226, 35)) + + o.foo; +>o.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 226, 14)) +>foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) + } + if (o?.["foo"] === value) { +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 226, 14)) +>value : Symbol(value, Decl(controlFlowOptionalChain.ts, 226, 35)) + + o["foo"]; +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 226, 14)) +>"foo" : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) + } + if (o?.bar() === value) { +>o?.bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 36)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 226, 14)) +>bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 36)) +>value : Symbol(value, Decl(controlFlowOptionalChain.ts, 226, 35)) + + o.bar; +>o.bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 36)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 226, 14)) +>bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 36)) + } + if (o?.foo == value) { +>o?.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 226, 14)) +>foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>value : Symbol(value, Decl(controlFlowOptionalChain.ts, 226, 35)) + + o.foo; // Error +>o.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 226, 14)) +>foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) + } + if (o?.["foo"] == value) { +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 226, 14)) +>value : Symbol(value, Decl(controlFlowOptionalChain.ts, 226, 35)) + + o["foo"]; // Error +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 226, 14)) + } + if (o?.bar() == value) { +>o?.bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 36)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 226, 14)) +>bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 36)) +>value : Symbol(value, Decl(controlFlowOptionalChain.ts, 226, 35)) + + o.bar; // Error +>o.bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 36)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 226, 14)) +>bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 36)) } } function f13(o: Thing | undefined) { ->f13 : Symbol(f13, Decl(controlFlowOptionalChain.ts, 206, 1)) ->o : Symbol(o, Decl(controlFlowOptionalChain.ts, 208, 13)) +>f13 : Symbol(f13, Decl(controlFlowOptionalChain.ts, 245, 1)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 247, 13)) >Thing : Symbol(Thing, Decl(controlFlowOptionalChain.ts, 159, 1)) if (o?.foo !== undefined) { >o?.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) ->o : Symbol(o, Decl(controlFlowOptionalChain.ts, 208, 13)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 247, 13)) >foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) >undefined : Symbol(undefined) - o; ->o : Symbol(o, Decl(controlFlowOptionalChain.ts, 208, 13)) - o.foo; >o.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) ->o : Symbol(o, Decl(controlFlowOptionalChain.ts, 208, 13)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 247, 13)) >foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) } if (o?.["foo"] !== undefined) { ->o : Symbol(o, Decl(controlFlowOptionalChain.ts, 208, 13)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 247, 13)) >undefined : Symbol(undefined) - o; ->o : Symbol(o, Decl(controlFlowOptionalChain.ts, 208, 13)) - o["foo"]; ->o : Symbol(o, Decl(controlFlowOptionalChain.ts, 208, 13)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 247, 13)) >"foo" : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) } if (o?.bar() !== undefined) { ->o?.bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 27)) ->o : Symbol(o, Decl(controlFlowOptionalChain.ts, 208, 13)) ->bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 27)) +>o?.bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 36)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 247, 13)) +>bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 36)) >undefined : Symbol(undefined) - o; ->o : Symbol(o, Decl(controlFlowOptionalChain.ts, 208, 13)) + o.bar; +>o.bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 36)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 247, 13)) +>bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 36)) + } + if (o?.foo != undefined) { +>o?.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 247, 13)) +>foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>undefined : Symbol(undefined) + + o.foo; +>o.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 247, 13)) +>foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) + } + if (o?.["foo"] != undefined) { +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 247, 13)) +>undefined : Symbol(undefined) + + o["foo"]; +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 247, 13)) +>"foo" : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) + } + if (o?.bar() != undefined) { +>o?.bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 36)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 247, 13)) +>bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 36)) +>undefined : Symbol(undefined) o.bar; ->o.bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 27)) ->o : Symbol(o, Decl(controlFlowOptionalChain.ts, 208, 13)) ->bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 27)) +>o.bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 36)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 247, 13)) +>bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 36)) + } +} + +function f13a(o: Thing | undefined) { +>f13a : Symbol(f13a, Decl(controlFlowOptionalChain.ts, 266, 1)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 268, 14)) +>Thing : Symbol(Thing, Decl(controlFlowOptionalChain.ts, 159, 1)) + + if (o?.foo !== null) { +>o?.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 268, 14)) +>foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) + + o.foo; // Error +>o.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 268, 14)) +>foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) + } + if (o?.["foo"] !== null) { +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 268, 14)) + + o["foo"]; // Error +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 268, 14)) + } + if (o?.bar() !== null) { +>o?.bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 36)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 268, 14)) +>bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 36)) + + o.bar; // Error +>o.bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 36)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 268, 14)) +>bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 36)) + } + if (o?.foo != null) { +>o?.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 268, 14)) +>foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) + + o.foo; +>o.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 268, 14)) +>foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) + } + if (o?.["foo"] != null) { +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 268, 14)) + + o["foo"]; +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 268, 14)) +>"foo" : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) + } + if (o?.bar() != null) { +>o?.bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 36)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 268, 14)) +>bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 36)) + + o.bar; +>o.bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 36)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 268, 14)) +>bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 36)) } } function f14(o: Thing | null) { ->f14 : Symbol(f14, Decl(controlFlowOptionalChain.ts, 221, 1)) ->o : Symbol(o, Decl(controlFlowOptionalChain.ts, 223, 13)) +>f14 : Symbol(f14, Decl(controlFlowOptionalChain.ts, 287, 1)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 289, 13)) >Thing : Symbol(Thing, Decl(controlFlowOptionalChain.ts, 159, 1)) if (o?.foo !== undefined) { >o?.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) ->o : Symbol(o, Decl(controlFlowOptionalChain.ts, 223, 13)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 289, 13)) >foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) >undefined : Symbol(undefined) - o; ->o : Symbol(o, Decl(controlFlowOptionalChain.ts, 223, 13)) - o.foo; >o.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) ->o : Symbol(o, Decl(controlFlowOptionalChain.ts, 223, 13)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 289, 13)) >foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) } if (o?.["foo"] !== undefined) { ->o : Symbol(o, Decl(controlFlowOptionalChain.ts, 223, 13)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 289, 13)) >undefined : Symbol(undefined) - o; ->o : Symbol(o, Decl(controlFlowOptionalChain.ts, 223, 13)) - o["foo"]; ->o : Symbol(o, Decl(controlFlowOptionalChain.ts, 223, 13)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 289, 13)) >"foo" : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) } if (o?.bar() !== undefined) { ->o?.bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 27)) ->o : Symbol(o, Decl(controlFlowOptionalChain.ts, 223, 13)) ->bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 27)) +>o?.bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 36)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 289, 13)) +>bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 36)) >undefined : Symbol(undefined) - o; ->o : Symbol(o, Decl(controlFlowOptionalChain.ts, 223, 13)) - o.bar; ->o.bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 27)) ->o : Symbol(o, Decl(controlFlowOptionalChain.ts, 223, 13)) ->bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 27)) +>o.bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 36)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 289, 13)) +>bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 36)) + } +} + +function f20(o: Thing | undefined) { +>f20 : Symbol(f20, Decl(controlFlowOptionalChain.ts, 299, 1)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 301, 13)) +>Thing : Symbol(Thing, Decl(controlFlowOptionalChain.ts, 159, 1)) + + if (typeof o?.foo === "number") { +>o?.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 301, 13)) +>foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) + + o.foo; +>o.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 301, 13)) +>foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) + } + if (typeof o?.["foo"] === "number") { +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 301, 13)) + + o["foo"]; +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 301, 13)) +>"foo" : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) + } + if (typeof o?.bar() === "number") { +>o?.bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 36)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 301, 13)) +>bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 36)) + + o.bar; +>o.bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 36)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 301, 13)) +>bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 36)) + } + if (o?.baz instanceof Error) { +>o?.baz : Symbol(baz, Decl(controlFlowOptionalChain.ts, 161, 51)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 301, 13)) +>baz : Symbol(baz, Decl(controlFlowOptionalChain.ts, 161, 51)) +>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) + + o.baz; +>o.baz : Symbol(baz, Decl(controlFlowOptionalChain.ts, 161, 51)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 301, 13)) +>baz : Symbol(baz, Decl(controlFlowOptionalChain.ts, 161, 51)) + } +} + +function f21(o: Thing | null) { +>f21 : Symbol(f21, Decl(controlFlowOptionalChain.ts, 314, 1)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 316, 13)) +>Thing : Symbol(Thing, Decl(controlFlowOptionalChain.ts, 159, 1)) + + if (typeof o?.foo === "number") { +>o?.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 316, 13)) +>foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) + + o.foo; +>o.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 316, 13)) +>foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) + } + if (typeof o?.["foo"] === "number") { +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 316, 13)) + + o["foo"]; +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 316, 13)) +>"foo" : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14)) + } + if (typeof o?.bar() === "number") { +>o?.bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 36)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 316, 13)) +>bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 36)) + + o.bar; +>o.bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 36)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 316, 13)) +>bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 36)) + } + if (o?.baz instanceof Error) { +>o?.baz : Symbol(baz, Decl(controlFlowOptionalChain.ts, 161, 51)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 316, 13)) +>baz : Symbol(baz, Decl(controlFlowOptionalChain.ts, 161, 51)) +>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) + + o.baz; +>o.baz : Symbol(baz, Decl(controlFlowOptionalChain.ts, 161, 51)) +>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 316, 13)) +>baz : Symbol(baz, Decl(controlFlowOptionalChain.ts, 161, 51)) } } diff --git a/tests/baselines/reference/controlFlowOptionalChain.types b/tests/baselines/reference/controlFlowOptionalChain.types index 0c243dc6be6..ffec7d1525e 100644 --- a/tests/baselines/reference/controlFlowOptionalChain.types +++ b/tests/baselines/reference/controlFlowOptionalChain.types @@ -634,10 +634,11 @@ function f01(x: unknown) { } } -type Thing = { foo: number, bar(): number }; +type Thing = { foo: string | number, bar(): number, baz: object }; >Thing : Thing ->foo : number +>foo : string | number >bar : () => number +>baz : object function f10(o: Thing | undefined, value: number) { >f10 : (o: Thing | undefined, value: number) => void @@ -646,14 +647,11 @@ function f10(o: Thing | undefined, value: number) { if (o?.foo === value) { >o?.foo === value : boolean ->o?.foo : number | undefined +>o?.foo : string | number | undefined >o : Thing | undefined ->foo : number | undefined +>foo : string | number | undefined >value : number - o; ->o : Thing - o.foo; >o.foo : number >o : Thing @@ -661,14 +659,11 @@ function f10(o: Thing | undefined, value: number) { } if (o?.["foo"] === value) { >o?.["foo"] === value : boolean ->o?.["foo"] : number | undefined +>o?.["foo"] : string | number | undefined >o : Thing | undefined >"foo" : "foo" >value : number - o; ->o : Thing - o["foo"]; >o["foo"] : number >o : Thing @@ -682,8 +677,42 @@ function f10(o: Thing | undefined, value: number) { >bar : (() => number) | undefined >value : number - o; + o.bar; +>o.bar : () => number >o : Thing +>bar : () => number + } + if (o?.foo == value) { +>o?.foo == value : boolean +>o?.foo : string | number | undefined +>o : Thing | undefined +>foo : string | number | undefined +>value : number + + o.foo; +>o.foo : string | number +>o : Thing +>foo : string | number + } + if (o?.["foo"] == value) { +>o?.["foo"] == value : boolean +>o?.["foo"] : string | number | undefined +>o : Thing | undefined +>"foo" : "foo" +>value : number + + o["foo"]; +>o["foo"] : string | number +>o : Thing +>"foo" : "foo" + } + if (o?.bar() == value) { +>o?.bar() == value : boolean +>o?.bar() : number | undefined +>o?.bar : (() => number) | undefined +>o : Thing | undefined +>bar : (() => number) | undefined +>value : number o.bar; >o.bar : () => number @@ -700,14 +729,11 @@ function f11(o: Thing | null, value: number) { if (o?.foo === value) { >o?.foo === value : boolean ->o?.foo : number | undefined +>o?.foo : string | number | undefined >o : Thing | null ->foo : number | undefined +>foo : string | number | undefined >value : number - o; ->o : Thing - o.foo; >o.foo : number >o : Thing @@ -715,14 +741,11 @@ function f11(o: Thing | null, value: number) { } if (o?.["foo"] === value) { >o?.["foo"] === value : boolean ->o?.["foo"] : number | undefined +>o?.["foo"] : string | number | undefined >o : Thing | null >"foo" : "foo" >value : number - o; ->o : Thing - o["foo"]; >o["foo"] : number >o : Thing @@ -736,8 +759,42 @@ function f11(o: Thing | null, value: number) { >bar : (() => number) | undefined >value : number - o; + o.bar; +>o.bar : () => number >o : Thing +>bar : () => number + } + if (o?.foo == value) { +>o?.foo == value : boolean +>o?.foo : string | number | undefined +>o : Thing | null +>foo : string | number | undefined +>value : number + + o.foo; +>o.foo : string | number +>o : Thing +>foo : string | number + } + if (o?.["foo"] == value) { +>o?.["foo"] == value : boolean +>o?.["foo"] : string | number | undefined +>o : Thing | null +>"foo" : "foo" +>value : number + + o["foo"]; +>o["foo"] : string | number +>o : Thing +>"foo" : "foo" + } + if (o?.bar() == value) { +>o?.bar() == value : boolean +>o?.bar() : number | undefined +>o?.bar : (() => number) | undefined +>o : Thing | null +>bar : (() => number) | undefined +>value : number o.bar; >o.bar : () => number @@ -753,14 +810,11 @@ function f12(o: Thing | undefined, value: number | undefined) { if (o?.foo === value) { >o?.foo === value : boolean ->o?.foo : number | undefined +>o?.foo : string | number | undefined >o : Thing | undefined ->foo : number | undefined +>foo : string | number | undefined >value : number | undefined - o; ->o : Thing | undefined - o.foo; // Error >o.foo : number >o : Thing | undefined @@ -768,14 +822,11 @@ function f12(o: Thing | undefined, value: number | undefined) { } if (o?.["foo"] === value) { >o?.["foo"] === value : boolean ->o?.["foo"] : number | undefined +>o?.["foo"] : string | number | undefined >o : Thing | undefined >"foo" : "foo" >value : number | undefined - o; ->o : Thing | undefined - o["foo"]; // Error >o["foo"] : number >o : Thing | undefined @@ -789,8 +840,124 @@ function f12(o: Thing | undefined, value: number | undefined) { >bar : (() => number) | undefined >value : number | undefined - o; + o.bar; // Error +>o.bar : () => number >o : Thing | undefined +>bar : () => number + } + if (o?.foo == value) { +>o?.foo == value : boolean +>o?.foo : string | number | undefined +>o : Thing | undefined +>foo : string | number | undefined +>value : number | undefined + + o.foo; // Error +>o.foo : number +>o : Thing | undefined +>foo : number + } + if (o?.["foo"] == value) { +>o?.["foo"] == value : boolean +>o?.["foo"] : string | number | undefined +>o : Thing | undefined +>"foo" : "foo" +>value : number | undefined + + o["foo"]; // Error +>o["foo"] : number +>o : Thing | undefined +>"foo" : "foo" + } + if (o?.bar() == value) { +>o?.bar() == value : boolean +>o?.bar() : number | undefined +>o?.bar : (() => number) | undefined +>o : Thing | undefined +>bar : (() => number) | undefined +>value : number | undefined + + o.bar; // Error +>o.bar : () => number +>o : Thing | undefined +>bar : () => number + } +} + +function f12a(o: Thing | undefined, value: number | null) { +>f12a : (o: Thing | undefined, value: number | null) => void +>o : Thing | undefined +>value : number | null +>null : null + + if (o?.foo === value) { +>o?.foo === value : boolean +>o?.foo : string | number | undefined +>o : Thing | undefined +>foo : string | number | undefined +>value : number | null + + o.foo; +>o.foo : number +>o : Thing +>foo : number + } + if (o?.["foo"] === value) { +>o?.["foo"] === value : boolean +>o?.["foo"] : string | number | undefined +>o : Thing | undefined +>"foo" : "foo" +>value : number | null + + o["foo"]; +>o["foo"] : number +>o : Thing +>"foo" : "foo" + } + if (o?.bar() === value) { +>o?.bar() === value : boolean +>o?.bar() : number | undefined +>o?.bar : (() => number) | undefined +>o : Thing | undefined +>bar : (() => number) | undefined +>value : number | null + + o.bar; +>o.bar : () => number +>o : Thing +>bar : () => number + } + if (o?.foo == value) { +>o?.foo == value : boolean +>o?.foo : string | number | undefined +>o : Thing | undefined +>foo : string | number | undefined +>value : number | null + + o.foo; // Error +>o.foo : number +>o : Thing | undefined +>foo : number + } + if (o?.["foo"] == value) { +>o?.["foo"] == value : boolean +>o?.["foo"] : string | number | undefined +>o : Thing | undefined +>"foo" : "foo" +>value : number | null + + o["foo"]; // Error +>o["foo"] : number +>o : Thing | undefined +>"foo" : "foo" + } + if (o?.bar() == value) { +>o?.bar() == value : boolean +>o?.bar() : number | undefined +>o?.bar : (() => number) | undefined +>o : Thing | undefined +>bar : (() => number) | undefined +>value : number | null o.bar; // Error >o.bar : () => number @@ -805,31 +972,25 @@ function f13(o: Thing | undefined) { if (o?.foo !== undefined) { >o?.foo !== undefined : boolean ->o?.foo : number | undefined +>o?.foo : string | number | undefined >o : Thing | undefined ->foo : number | undefined +>foo : string | number | undefined >undefined : undefined - o; ->o : Thing - o.foo; ->o.foo : number +>o.foo : string | number >o : Thing ->foo : number +>foo : string | number } if (o?.["foo"] !== undefined) { >o?.["foo"] !== undefined : boolean ->o?.["foo"] : number | undefined +>o?.["foo"] : string | number | undefined >o : Thing | undefined >"foo" : "foo" >undefined : undefined - o; ->o : Thing - o["foo"]; ->o["foo"] : number +>o["foo"] : string | number >o : Thing >"foo" : "foo" } @@ -841,8 +1002,122 @@ function f13(o: Thing | undefined) { >bar : (() => number) | undefined >undefined : undefined - o; + o.bar; +>o.bar : () => number >o : Thing +>bar : () => number + } + if (o?.foo != undefined) { +>o?.foo != undefined : boolean +>o?.foo : string | number | undefined +>o : Thing | undefined +>foo : string | number | undefined +>undefined : undefined + + o.foo; +>o.foo : string | number +>o : Thing +>foo : string | number + } + if (o?.["foo"] != undefined) { +>o?.["foo"] != undefined : boolean +>o?.["foo"] : string | number | undefined +>o : Thing | undefined +>"foo" : "foo" +>undefined : undefined + + o["foo"]; +>o["foo"] : string | number +>o : Thing +>"foo" : "foo" + } + if (o?.bar() != undefined) { +>o?.bar() != undefined : boolean +>o?.bar() : number | undefined +>o?.bar : (() => number) | undefined +>o : Thing | undefined +>bar : (() => number) | undefined +>undefined : undefined + + o.bar; +>o.bar : () => number +>o : Thing +>bar : () => number + } +} + +function f13a(o: Thing | undefined) { +>f13a : (o: Thing | undefined) => void +>o : Thing | undefined + + if (o?.foo !== null) { +>o?.foo !== null : boolean +>o?.foo : string | number | undefined +>o : Thing | undefined +>foo : string | number | undefined +>null : null + + o.foo; // Error +>o.foo : string | number +>o : Thing | undefined +>foo : string | number + } + if (o?.["foo"] !== null) { +>o?.["foo"] !== null : boolean +>o?.["foo"] : string | number | undefined +>o : Thing | undefined +>"foo" : "foo" +>null : null + + o["foo"]; // Error +>o["foo"] : string | number +>o : Thing | undefined +>"foo" : "foo" + } + if (o?.bar() !== null) { +>o?.bar() !== null : boolean +>o?.bar() : number | undefined +>o?.bar : (() => number) | undefined +>o : Thing | undefined +>bar : (() => number) | undefined +>null : null + + o.bar; // Error +>o.bar : () => number +>o : Thing | undefined +>bar : () => number + } + if (o?.foo != null) { +>o?.foo != null : boolean +>o?.foo : string | number | undefined +>o : Thing | undefined +>foo : string | number | undefined +>null : null + + o.foo; +>o.foo : string | number +>o : Thing +>foo : string | number + } + if (o?.["foo"] != null) { +>o?.["foo"] != null : boolean +>o?.["foo"] : string | number | undefined +>o : Thing | undefined +>"foo" : "foo" +>null : null + + o["foo"]; +>o["foo"] : string | number +>o : Thing +>"foo" : "foo" + } + if (o?.bar() != null) { +>o?.bar() != null : boolean +>o?.bar() : number | undefined +>o?.bar : (() => number) | undefined +>o : Thing | undefined +>bar : (() => number) | undefined +>null : null o.bar; >o.bar : () => number @@ -858,31 +1133,25 @@ function f14(o: Thing | null) { if (o?.foo !== undefined) { >o?.foo !== undefined : boolean ->o?.foo : number | undefined +>o?.foo : string | number | undefined >o : Thing | null ->foo : number | undefined +>foo : string | number | undefined >undefined : undefined - o; ->o : Thing - o.foo; ->o.foo : number +>o.foo : string | number >o : Thing ->foo : number +>foo : string | number } if (o?.["foo"] !== undefined) { >o?.["foo"] !== undefined : boolean ->o?.["foo"] : number | undefined +>o?.["foo"] : string | number | undefined >o : Thing | null >"foo" : "foo" >undefined : undefined - o; ->o : Thing - o["foo"]; ->o["foo"] : number +>o["foo"] : string | number >o : Thing >"foo" : "foo" } @@ -894,9 +1163,6 @@ function f14(o: Thing | null) { >bar : (() => number) | undefined >undefined : undefined - o; ->o : Thing - o.bar; >o.bar : () => number >o : Thing @@ -904,3 +1170,120 @@ function f14(o: Thing | null) { } } +function f20(o: Thing | undefined) { +>f20 : (o: Thing | undefined) => void +>o : Thing | undefined + + if (typeof o?.foo === "number") { +>typeof o?.foo === "number" : boolean +>typeof o?.foo : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" +>o?.foo : string | number | undefined +>o : Thing | undefined +>foo : string | number | undefined +>"number" : "number" + + o.foo; +>o.foo : number +>o : Thing +>foo : number + } + if (typeof o?.["foo"] === "number") { +>typeof o?.["foo"] === "number" : boolean +>typeof o?.["foo"] : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" +>o?.["foo"] : string | number | undefined +>o : Thing | undefined +>"foo" : "foo" +>"number" : "number" + + o["foo"]; +>o["foo"] : number +>o : Thing +>"foo" : "foo" + } + if (typeof o?.bar() === "number") { +>typeof o?.bar() === "number" : boolean +>typeof o?.bar() : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" +>o?.bar() : number | undefined +>o?.bar : (() => number) | undefined +>o : Thing | undefined +>bar : (() => number) | undefined +>"number" : "number" + + o.bar; +>o.bar : () => number +>o : Thing +>bar : () => number + } + if (o?.baz instanceof Error) { +>o?.baz instanceof Error : boolean +>o?.baz : object | undefined +>o : Thing | undefined +>baz : object | undefined +>Error : ErrorConstructor + + o.baz; +>o.baz : Error +>o : Thing +>baz : Error + } +} + +function f21(o: Thing | null) { +>f21 : (o: Thing | null) => void +>o : Thing | null +>null : null + + if (typeof o?.foo === "number") { +>typeof o?.foo === "number" : boolean +>typeof o?.foo : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" +>o?.foo : string | number | undefined +>o : Thing | null +>foo : string | number | undefined +>"number" : "number" + + o.foo; +>o.foo : number +>o : Thing +>foo : number + } + if (typeof o?.["foo"] === "number") { +>typeof o?.["foo"] === "number" : boolean +>typeof o?.["foo"] : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" +>o?.["foo"] : string | number | undefined +>o : Thing | null +>"foo" : "foo" +>"number" : "number" + + o["foo"]; +>o["foo"] : number +>o : Thing +>"foo" : "foo" + } + if (typeof o?.bar() === "number") { +>typeof o?.bar() === "number" : boolean +>typeof o?.bar() : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" +>o?.bar() : number | undefined +>o?.bar : (() => number) | undefined +>o : Thing | null +>bar : (() => number) | undefined +>"number" : "number" + + o.bar; +>o.bar : () => number +>o : Thing +>bar : () => number + } + if (o?.baz instanceof Error) { +>o?.baz instanceof Error : boolean +>o?.baz : object | undefined +>o : Thing | null +>baz : object | undefined +>Error : ErrorConstructor + + o.baz; +>o.baz : Error +>o : Thing +>baz : Error + } +} +