From 7d32355f957dd5547aa0a7a50d1a1c2a56d90bf8 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Fri, 4 Oct 2019 16:01:27 -0700 Subject: [PATCH] Accept new baselines --- .../reference/controlFlowOptionalChain.errors.txt | 9 +++------ .../reference/controlFlowOptionalChain.js | 8 ++++---- .../reference/controlFlowOptionalChain.symbols | 12 ++++++------ .../reference/controlFlowOptionalChain.types | 14 +++++++------- 4 files changed, 20 insertions(+), 23 deletions(-) diff --git a/tests/baselines/reference/controlFlowOptionalChain.errors.txt b/tests/baselines/reference/controlFlowOptionalChain.errors.txt index ce46b232b3d..0d2d268d591 100644 --- a/tests/baselines/reference/controlFlowOptionalChain.errors.txt +++ b/tests/baselines/reference/controlFlowOptionalChain.errors.txt @@ -6,7 +6,6 @@ tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts(35,5): error TS2 tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts(39,1): error TS2722: Cannot invoke an object which is possibly 'undefined'. tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts(52,5): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts(57,1): error TS2532: Object is possibly 'undefined'. -tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts(62,5): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts(68,5): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts(72,1): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts(83,5): error TS2532: Object is possibly 'undefined'. @@ -22,7 +21,7 @@ tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts(134,1): error TS 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 (22 errors) ==== +==== tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts (21 errors) ==== // assignments in shortcutting chain declare const o: undefined | { [key: string]: any; @@ -99,10 +98,8 @@ tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts(153,9): error TS declare const o3: { x: 1, y: string } | { x: 2, y: number } | undefined; if (o3?.x === 1) { - o3; // TODO: should be `{ x: y, y: string }` - o3.x; // TODO: should not be an error. - ~~ -!!! error TS2532: Object is possibly 'undefined'. + o3; + o3.x; o3?.x; } else { diff --git a/tests/baselines/reference/controlFlowOptionalChain.js b/tests/baselines/reference/controlFlowOptionalChain.js index 58a2873f93a..fed8131681f 100644 --- a/tests/baselines/reference/controlFlowOptionalChain.js +++ b/tests/baselines/reference/controlFlowOptionalChain.js @@ -59,8 +59,8 @@ o2.f; declare const o3: { x: 1, y: string } | { x: 2, y: number } | undefined; if (o3?.x === 1) { - o3; // TODO: should be `{ x: y, y: string }` - o3.x; // TODO: should not be an error. + o3; + o3.x; o3?.x; } else { @@ -206,8 +206,8 @@ o2; (_k = o2) === null || _k === void 0 ? void 0 : _k.f; o2.f; if (((_l = o3) === null || _l === void 0 ? void 0 : _l.x) === 1) { - o3; // TODO: should be `{ x: y, y: string }` - o3.x; // TODO: should not be an error. + o3; + o3.x; (_m = o3) === null || _m === void 0 ? void 0 : _m.x; } else { diff --git a/tests/baselines/reference/controlFlowOptionalChain.symbols b/tests/baselines/reference/controlFlowOptionalChain.symbols index 21f1de2a410..d3390729ac4 100644 --- a/tests/baselines/reference/controlFlowOptionalChain.symbols +++ b/tests/baselines/reference/controlFlowOptionalChain.symbols @@ -182,18 +182,18 @@ if (o3?.x === 1) { >o3 : Symbol(o3, Decl(controlFlowOptionalChain.ts, 58, 13)) >x : Symbol(x, Decl(controlFlowOptionalChain.ts, 58, 19), Decl(controlFlowOptionalChain.ts, 58, 41)) - o3; // TODO: should be `{ x: y, y: string }` + o3; >o3 : Symbol(o3, Decl(controlFlowOptionalChain.ts, 58, 13)) - o3.x; // TODO: should not be an error. ->o3.x : Symbol(x, Decl(controlFlowOptionalChain.ts, 58, 19), Decl(controlFlowOptionalChain.ts, 58, 41)) + o3.x; +>o3.x : Symbol(x, Decl(controlFlowOptionalChain.ts, 58, 19)) >o3 : Symbol(o3, Decl(controlFlowOptionalChain.ts, 58, 13)) ->x : Symbol(x, Decl(controlFlowOptionalChain.ts, 58, 19), Decl(controlFlowOptionalChain.ts, 58, 41)) +>x : Symbol(x, Decl(controlFlowOptionalChain.ts, 58, 19)) o3?.x; ->o3?.x : Symbol(x, Decl(controlFlowOptionalChain.ts, 58, 19), Decl(controlFlowOptionalChain.ts, 58, 41)) +>o3?.x : Symbol(x, Decl(controlFlowOptionalChain.ts, 58, 19)) >o3 : Symbol(o3, Decl(controlFlowOptionalChain.ts, 58, 13)) ->x : Symbol(x, Decl(controlFlowOptionalChain.ts, 58, 19), Decl(controlFlowOptionalChain.ts, 58, 41)) +>x : Symbol(x, Decl(controlFlowOptionalChain.ts, 58, 19)) } else { o3; diff --git a/tests/baselines/reference/controlFlowOptionalChain.types b/tests/baselines/reference/controlFlowOptionalChain.types index a93c5b0b43f..5b9d10b2198 100644 --- a/tests/baselines/reference/controlFlowOptionalChain.types +++ b/tests/baselines/reference/controlFlowOptionalChain.types @@ -208,18 +208,18 @@ if (o3?.x === 1) { >x : 1 | 2 | undefined >1 : 1 - o3; // TODO: should be `{ x: y, y: string }` ->o3 : { x: 1; y: string; } | { x: 2; y: number; } | undefined + o3; +>o3 : { x: 1; y: string; } - o3.x; // TODO: should not be an error. + o3.x; >o3.x : 1 ->o3 : { x: 1; y: string; } | { x: 2; y: number; } | undefined +>o3 : { x: 1; y: string; } >x : 1 o3?.x; ->o3?.x : 1 | undefined ->o3 : { x: 1; y: string; } | { x: 2; y: number; } | undefined ->x : 1 | undefined +>o3?.x : 1 +>o3 : { x: 1; y: string; } +>x : 1 } else { o3;