Accept new baselines

This commit is contained in:
Anders Hejlsberg
2019-10-04 16:12:53 -07:00
parent 42500d0606
commit 464d1a74c7
4 changed files with 746 additions and 1 deletions
@@ -19,9 +19,12 @@ 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 (21 errors) ====
==== tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts (24 errors) ====
// assignments in shortcutting chain
declare const o: undefined | {
[key: string]: any;
@@ -224,4 +227,87 @@ tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts(153,9): error TS
x;
}
}
type Thing = { foo: number, bar(): number };
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;
}
}
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;
}
}
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'.
}
}
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;
}
}
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;
}
}
@@ -159,6 +159,83 @@ function f01(x: unknown) {
x;
}
}
type Thing = { foo: number, bar(): number };
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;
}
}
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;
}
}
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
}
}
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;
}
}
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;
}
}
//// [controlFlowOptionalChain.js]
@@ -286,3 +363,78 @@ function f01(x) {
x;
}
}
function f10(o, value) {
var _a, _b, _c;
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;
}
}
function f11(o, value) {
var _a, _b, _c;
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;
}
}
function f12(o, value) {
var _a, _b, _c;
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
}
}
function f13(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 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;
}
}
@@ -600,3 +600,240 @@ function f01(x: unknown) {
}
}
type Thing = { foo: number, bar(): number };
>Thing : Symbol(Thing, Decl(controlFlowOptionalChain.ts, 159, 1))
>foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14))
>bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 27))
function f10(o: Thing | undefined, value: number) {
>f10 : Symbol(f10, Decl(controlFlowOptionalChain.ts, 161, 44))
>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 163, 13))
>Thing : Symbol(Thing, Decl(controlFlowOptionalChain.ts, 159, 1))
>value : Symbol(value, Decl(controlFlowOptionalChain.ts, 163, 34))
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;
>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))
>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;
>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 : Symbol(o, Decl(controlFlowOptionalChain.ts, 163, 13))
>bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 27))
>value : Symbol(value, Decl(controlFlowOptionalChain.ts, 163, 34))
o;
>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 163, 13))
o.bar;
>o.bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 27))
>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 163, 13))
>bar : Symbol(bar, Decl(controlFlowOptionalChain.ts, 161, 27))
}
}
function f11(o: Thing | null, value: number) {
>f11 : Symbol(f11, Decl(controlFlowOptionalChain.ts, 176, 1))
>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 178, 13))
>Thing : Symbol(Thing, Decl(controlFlowOptionalChain.ts, 159, 1))
>value : Symbol(value, Decl(controlFlowOptionalChain.ts, 178, 29))
if (o?.foo === value) {
>o?.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14))
>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 178, 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))
o.foo;
>o.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14))
>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 178, 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["foo"];
>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 178, 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;
>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))
}
}
function f12(o: Thing | undefined, value: number | undefined) {
>f12 : Symbol(f12, Decl(controlFlowOptionalChain.ts, 191, 1))
>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 193, 13))
>Thing : Symbol(Thing, Decl(controlFlowOptionalChain.ts, 159, 1))
>value : Symbol(value, Decl(controlFlowOptionalChain.ts, 193, 34))
if (o?.foo === value) {
>o?.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14))
>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 193, 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))
o.foo; // Error
>o.foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14))
>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 193, 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["foo"]; // Error
>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 193, 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; // 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))
}
}
function f13(o: Thing | undefined) {
>f13 : Symbol(f13, Decl(controlFlowOptionalChain.ts, 206, 1))
>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 208, 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))
>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))
>foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14))
}
if (o?.["foo"] !== undefined) {
>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 208, 13))
>undefined : Symbol(undefined)
o;
>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 208, 13))
o["foo"];
>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 208, 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))
>undefined : Symbol(undefined)
o;
>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 208, 13))
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))
}
}
function f14(o: Thing | null) {
>f14 : Symbol(f14, Decl(controlFlowOptionalChain.ts, 221, 1))
>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 223, 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))
>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))
>foo : Symbol(foo, Decl(controlFlowOptionalChain.ts, 161, 14))
}
if (o?.["foo"] !== undefined) {
>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 223, 13))
>undefined : Symbol(undefined)
o;
>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 223, 13))
o["foo"];
>o : Symbol(o, Decl(controlFlowOptionalChain.ts, 223, 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))
>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))
}
}
@@ -634,3 +634,273 @@ function f01(x: unknown) {
}
}
type Thing = { foo: number, bar(): number };
>Thing : Thing
>foo : number
>bar : () => number
function f10(o: Thing | undefined, value: number) {
>f10 : (o: Thing | undefined, value: number) => void
>o : Thing | undefined
>value : number
if (o?.foo === value) {
>o?.foo === value : boolean
>o?.foo : number | undefined
>o : Thing | undefined
>foo : number | undefined
>value : number
o;
>o : Thing
o.foo;
>o.foo : number
>o : Thing
>foo : number
}
if (o?.["foo"] === value) {
>o?.["foo"] === value : boolean
>o?.["foo"] : number | undefined
>o : Thing | undefined
>"foo" : "foo"
>value : number
o;
>o : Thing
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
o;
>o : Thing
o.bar;
>o.bar : () => number
>o : Thing
>bar : () => number
}
}
function f11(o: Thing | null, value: number) {
>f11 : (o: Thing | null, value: number) => void
>o : Thing | null
>null : null
>value : number
if (o?.foo === value) {
>o?.foo === value : boolean
>o?.foo : number | undefined
>o : Thing | null
>foo : number | undefined
>value : number
o;
>o : Thing
o.foo;
>o.foo : number
>o : Thing
>foo : number
}
if (o?.["foo"] === value) {
>o?.["foo"] === value : boolean
>o?.["foo"] : number | undefined
>o : Thing | null
>"foo" : "foo"
>value : number
o;
>o : Thing
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 | null
>bar : (() => number) | undefined
>value : number
o;
>o : Thing
o.bar;
>o.bar : () => number
>o : Thing
>bar : () => number
}
}
function f12(o: Thing | undefined, value: number | undefined) {
>f12 : (o: Thing | undefined, value: number | undefined) => void
>o : Thing | undefined
>value : number | undefined
if (o?.foo === value) {
>o?.foo === value : boolean
>o?.foo : number | undefined
>o : Thing | undefined
>foo : number | undefined
>value : number | undefined
o;
>o : Thing | undefined
o.foo; // Error
>o.foo : number
>o : Thing | undefined
>foo : number
}
if (o?.["foo"] === value) {
>o?.["foo"] === value : boolean
>o?.["foo"] : number | undefined
>o : Thing | undefined
>"foo" : "foo"
>value : number | undefined
o;
>o : Thing | 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;
>o : Thing | undefined
o.bar; // Error
>o.bar : () => number
>o : Thing | undefined
>bar : () => number
}
}
function f13(o: Thing | undefined) {
>f13 : (o: Thing | undefined) => void
>o : Thing | undefined
if (o?.foo !== undefined) {
>o?.foo !== undefined : boolean
>o?.foo : number | undefined
>o : Thing | undefined
>foo : number | undefined
>undefined : undefined
o;
>o : Thing
o.foo;
>o.foo : number
>o : Thing
>foo : number
}
if (o?.["foo"] !== undefined) {
>o?.["foo"] !== undefined : boolean
>o?.["foo"] : number | undefined
>o : Thing | undefined
>"foo" : "foo"
>undefined : undefined
o;
>o : Thing
o["foo"];
>o["foo"] : 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;
>o : Thing
o.bar;
>o.bar : () => number
>o : Thing
>bar : () => number
}
}
function f14(o: Thing | null) {
>f14 : (o: Thing | null) => void
>o : Thing | null
>null : null
if (o?.foo !== undefined) {
>o?.foo !== undefined : boolean
>o?.foo : number | undefined
>o : Thing | null
>foo : number | undefined
>undefined : undefined
o;
>o : Thing
o.foo;
>o.foo : number
>o : Thing
>foo : number
}
if (o?.["foo"] !== undefined) {
>o?.["foo"] !== undefined : boolean
>o?.["foo"] : number | undefined
>o : Thing | null
>"foo" : "foo"
>undefined : undefined
o;
>o : Thing
o["foo"];
>o["foo"] : number
>o : Thing
>"foo" : "foo"
}
if (o?.bar() !== undefined) {
>o?.bar() !== undefined : boolean
>o?.bar() : number | undefined
>o?.bar : (() => number) | undefined
>o : Thing | null
>bar : (() => number) | undefined
>undefined : undefined
o;
>o : Thing
o.bar;
>o.bar : () => number
>o : Thing
>bar : () => number
}
}