From 735f166f4e6eaa5c4fed9f7f3e01cf63f877cd95 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Wed, 26 Sep 2018 11:09:28 -0700 Subject: [PATCH] Accept new baselines --- .../reference/controlFlowInstanceof.js | 15 ++++++- .../reference/controlFlowInstanceof.symbols | 18 +++++++++ .../reference/controlFlowInstanceof.types | 40 ++++++++++++++----- 3 files changed, 62 insertions(+), 11 deletions(-) diff --git a/tests/baselines/reference/controlFlowInstanceof.js b/tests/baselines/reference/controlFlowInstanceof.js index 89a8a7a3dd..1ac63f138f 100644 --- a/tests/baselines/reference/controlFlowInstanceof.js +++ b/tests/baselines/reference/controlFlowInstanceof.js @@ -95,7 +95,17 @@ function goo(x: X) { x.y; } x; -} +} + +// Repro from #27282 + +declare const x: (() => void)|null; +declare const ctor: Function; + +if (x instanceof ctor) { + x(); +} + //// [controlFlowInstanceof.js] // Repros from #10167 @@ -181,3 +191,6 @@ function goo(x) { } x; } +if (x instanceof ctor) { + x(); +} diff --git a/tests/baselines/reference/controlFlowInstanceof.symbols b/tests/baselines/reference/controlFlowInstanceof.symbols index 42e4485b5e..72ab32d29d 100644 --- a/tests/baselines/reference/controlFlowInstanceof.symbols +++ b/tests/baselines/reference/controlFlowInstanceof.symbols @@ -229,3 +229,21 @@ function goo(x: X) { x; >x : Symbol(x, Decl(controlFlowInstanceof.ts, 90, 13)) } + +// Repro from #27282 + +declare const x: (() => void)|null; +>x : Symbol(x, Decl(controlFlowInstanceof.ts, 100, 13)) + +declare const ctor: Function; +>ctor : Symbol(ctor, Decl(controlFlowInstanceof.ts, 101, 13)) +>Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) + +if (x instanceof ctor) { +>x : Symbol(x, Decl(controlFlowInstanceof.ts, 100, 13)) +>ctor : Symbol(ctor, Decl(controlFlowInstanceof.ts, 101, 13)) + + x(); +>x : Symbol(x, Decl(controlFlowInstanceof.ts, 100, 13)) +} + diff --git a/tests/baselines/reference/controlFlowInstanceof.types b/tests/baselines/reference/controlFlowInstanceof.types index d5405be948..e7c05a4c01 100644 --- a/tests/baselines/reference/controlFlowInstanceof.types +++ b/tests/baselines/reference/controlFlowInstanceof.types @@ -130,31 +130,31 @@ class C extends A { c: string } >c : string function foo(x: A | undefined) { ->foo : (x: A) => void ->x : A +>foo : (x: A | undefined) => void +>x : A | undefined x; // A | undefined ->x : A +>x : A | undefined if (x instanceof B || x instanceof C) { >x instanceof B || x instanceof C : boolean >x instanceof B : boolean ->x : A +>x : A | undefined >B : typeof B >x instanceof C : boolean ->x : A +>x : A | undefined >C : typeof C x; // B | C >x : B | C } x; // A | undefined ->x : A +>x : A | undefined if (x instanceof B && x instanceof C) { >x instanceof B && x instanceof C : boolean >x instanceof B : boolean ->x : A +>x : A | undefined >B : typeof B >x instanceof C : boolean >x : B @@ -164,11 +164,11 @@ function foo(x: A | undefined) { >x : B & C } x; // A | undefined ->x : A +>x : A | undefined if (!x) { >!x : boolean ->x : A +>x : A | undefined return; } @@ -211,7 +211,7 @@ function foo(x: A | undefined) { interface X { x?: string; ->x : string +>x : string | undefined } class Y { @@ -241,3 +241,23 @@ function goo(x: X) { x; >x : X } + +// Repro from #27282 + +declare const x: (() => void)|null; +>x : (() => void) | null +>null : null + +declare const ctor: Function; +>ctor : Function + +if (x instanceof ctor) { +>x instanceof ctor : boolean +>x : (() => void) | null +>ctor : Function + + x(); +>x() : void +>x : () => void +} +