From 1c8b30482659f7b27013f2faa9944d9bb18b8b23 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Thu, 4 Oct 2018 09:22:46 -0700 Subject: [PATCH 1/3] narrowTypeByInstanceof understands ctor funcs --- src/compiler/checker.ts | 9 +- .../reference/controlFlowInstanceof.js | 196 ------------------ .../reference/controlFlowInstanceof.symbols | 195 +++++++++-------- .../reference/controlFlowInstanceof.types | 30 ++- tests/cases/compiler/controlFlowInstanceof.ts | 14 ++ 5 files changed, 159 insertions(+), 285 deletions(-) delete mode 100644 tests/baselines/reference/controlFlowInstanceof.js diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 21518ca34d54e..160570c424759 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -15391,9 +15391,12 @@ namespace ts { } if (!targetType) { - const constructSignatures = getSignaturesOfType(rightType, SignatureKind.Construct); - targetType = constructSignatures && constructSignatures.length ? - getUnionType(map(constructSignatures, signature => getReturnTypeOfSignature(getErasedSignature(signature)))) : + let constructSignatures = getSignaturesOfType(rightType, SignatureKind.Construct); + if(constructSignatures.length === 0) { + constructSignatures = filter(getSignaturesOfType(rightType, SignatureKind.Call), sig => isJSConstructor(sig.declaration)); + } + targetType = constructSignatures.length ? + getUnionType(map(constructSignatures, signature => isJSConstructor(signature.declaration) && getJSClassType(getSymbolOfNode(signature.declaration!)) || getReturnTypeOfSignature(getErasedSignature(signature)))) : emptyObjectType; } diff --git a/tests/baselines/reference/controlFlowInstanceof.js b/tests/baselines/reference/controlFlowInstanceof.js deleted file mode 100644 index 1ac63f138f6e8..0000000000000 --- a/tests/baselines/reference/controlFlowInstanceof.js +++ /dev/null @@ -1,196 +0,0 @@ -//// [controlFlowInstanceof.ts] -// Repros from #10167 - -function f1(s: Set | Set) { - s = new Set(); - s; // Set - if (s instanceof Set) { - s; // Set - } - s; // Set - s.add(42); -} - -function f2(s: Set | Set) { - s = new Set(); - s; // Set - if (s instanceof Promise) { - s; // Set & Promise - } - s; // Set - s.add(42); -} - -function f3(s: Set | Set) { - s; // Set | Set - if (s instanceof Set) { - s; // Set | Set - } - else { - s; // never - } -} - -function f4(s: Set | Set) { - s = new Set(); - s; // Set - if (s instanceof Set) { - s; // Set - } - else { - s; // never - } -} - -// More tests - -class A { a: string } -class B extends A { b: string } -class C extends A { c: string } - -function foo(x: A | undefined) { - x; // A | undefined - if (x instanceof B || x instanceof C) { - x; // B | C - } - x; // A | undefined - if (x instanceof B && x instanceof C) { - x; // B & C - } - x; // A | undefined - if (!x) { - return; - } - x; // A - if (x instanceof B) { - x; // B - if (x instanceof C) { - x; // B & C - } - else { - x; // B - } - x; // B - } - else { - x; // A - } - x; // A -} - -// X is neither assignable to Y nor a subtype of Y -// Y is assignable to X, but not a subtype of X - -interface X { - x?: string; -} - -class Y { - y: string; -} - -function goo(x: X) { - x; - if (x instanceof Y) { - 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 -function f1(s) { - s = new Set(); - s; // Set - if (s instanceof Set) { - s; // Set - } - s; // Set - s.add(42); -} -function f2(s) { - s = new Set(); - s; // Set - if (s instanceof Promise) { - s; // Set & Promise - } - s; // Set - s.add(42); -} -function f3(s) { - s; // Set | Set - if (s instanceof Set) { - s; // Set | Set - } - else { - s; // never - } -} -function f4(s) { - s = new Set(); - s; // Set - if (s instanceof Set) { - s; // Set - } - else { - s; // never - } -} -// More tests -class A { -} -class B extends A { -} -class C extends A { -} -function foo(x) { - x; // A | undefined - if (x instanceof B || x instanceof C) { - x; // B | C - } - x; // A | undefined - if (x instanceof B && x instanceof C) { - x; // B & C - } - x; // A | undefined - if (!x) { - return; - } - x; // A - if (x instanceof B) { - x; // B - if (x instanceof C) { - x; // B & C - } - else { - x; // B - } - x; // B - } - else { - x; // A - } - x; // A -} -class Y { -} -function goo(x) { - x; - if (x instanceof Y) { - x.y; - } - x; -} -if (x instanceof ctor) { - x(); -} diff --git a/tests/baselines/reference/controlFlowInstanceof.symbols b/tests/baselines/reference/controlFlowInstanceof.symbols index 72ab32d29d52d..df3c552eb2ea9 100644 --- a/tests/baselines/reference/controlFlowInstanceof.symbols +++ b/tests/baselines/reference/controlFlowInstanceof.symbols @@ -1,249 +1,274 @@ -=== tests/cases/compiler/controlFlowInstanceof.ts === +=== tests/cases/compiler/ts.ts === // Repros from #10167 function f1(s: Set | Set) { ->f1 : Symbol(f1, Decl(controlFlowInstanceof.ts, 0, 0)) ->s : Symbol(s, Decl(controlFlowInstanceof.ts, 2, 12)) +>f1 : Symbol(f1, Decl(ts.ts, 0, 0)) +>s : Symbol(s, Decl(ts.ts, 2, 12)) >Set : Symbol(Set, Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) >Set : Symbol(Set, Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) s = new Set(); ->s : Symbol(s, Decl(controlFlowInstanceof.ts, 2, 12)) +>s : Symbol(s, Decl(ts.ts, 2, 12)) >Set : Symbol(Set, Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) s; // Set ->s : Symbol(s, Decl(controlFlowInstanceof.ts, 2, 12)) +>s : Symbol(s, Decl(ts.ts, 2, 12)) if (s instanceof Set) { ->s : Symbol(s, Decl(controlFlowInstanceof.ts, 2, 12)) +>s : Symbol(s, Decl(ts.ts, 2, 12)) >Set : Symbol(Set, Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) s; // Set ->s : Symbol(s, Decl(controlFlowInstanceof.ts, 2, 12)) +>s : Symbol(s, Decl(ts.ts, 2, 12)) } s; // Set ->s : Symbol(s, Decl(controlFlowInstanceof.ts, 2, 12)) +>s : Symbol(s, Decl(ts.ts, 2, 12)) s.add(42); >s.add : Symbol(Set.add, Decl(lib.es2015.collection.d.ts, --, --)) ->s : Symbol(s, Decl(controlFlowInstanceof.ts, 2, 12)) +>s : Symbol(s, Decl(ts.ts, 2, 12)) >add : Symbol(Set.add, Decl(lib.es2015.collection.d.ts, --, --)) } function f2(s: Set | Set) { ->f2 : Symbol(f2, Decl(controlFlowInstanceof.ts, 10, 1)) ->s : Symbol(s, Decl(controlFlowInstanceof.ts, 12, 12)) +>f2 : Symbol(f2, Decl(ts.ts, 10, 1)) +>s : Symbol(s, Decl(ts.ts, 12, 12)) >Set : Symbol(Set, Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) >Set : Symbol(Set, Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) s = new Set(); ->s : Symbol(s, Decl(controlFlowInstanceof.ts, 12, 12)) +>s : Symbol(s, Decl(ts.ts, 12, 12)) >Set : Symbol(Set, Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) s; // Set ->s : Symbol(s, Decl(controlFlowInstanceof.ts, 12, 12)) +>s : Symbol(s, Decl(ts.ts, 12, 12)) if (s instanceof Promise) { ->s : Symbol(s, Decl(controlFlowInstanceof.ts, 12, 12)) +>s : Symbol(s, Decl(ts.ts, 12, 12)) >Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) s; // Set & Promise ->s : Symbol(s, Decl(controlFlowInstanceof.ts, 12, 12)) +>s : Symbol(s, Decl(ts.ts, 12, 12)) } s; // Set ->s : Symbol(s, Decl(controlFlowInstanceof.ts, 12, 12)) +>s : Symbol(s, Decl(ts.ts, 12, 12)) s.add(42); >s.add : Symbol(Set.add, Decl(lib.es2015.collection.d.ts, --, --)) ->s : Symbol(s, Decl(controlFlowInstanceof.ts, 12, 12)) +>s : Symbol(s, Decl(ts.ts, 12, 12)) >add : Symbol(Set.add, Decl(lib.es2015.collection.d.ts, --, --)) } function f3(s: Set | Set) { ->f3 : Symbol(f3, Decl(controlFlowInstanceof.ts, 20, 1)) ->s : Symbol(s, Decl(controlFlowInstanceof.ts, 22, 12)) +>f3 : Symbol(f3, Decl(ts.ts, 20, 1)) +>s : Symbol(s, Decl(ts.ts, 22, 12)) >Set : Symbol(Set, Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) >Set : Symbol(Set, Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) s; // Set | Set ->s : Symbol(s, Decl(controlFlowInstanceof.ts, 22, 12)) +>s : Symbol(s, Decl(ts.ts, 22, 12)) if (s instanceof Set) { ->s : Symbol(s, Decl(controlFlowInstanceof.ts, 22, 12)) +>s : Symbol(s, Decl(ts.ts, 22, 12)) >Set : Symbol(Set, Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) s; // Set | Set ->s : Symbol(s, Decl(controlFlowInstanceof.ts, 22, 12)) +>s : Symbol(s, Decl(ts.ts, 22, 12)) } else { s; // never ->s : Symbol(s, Decl(controlFlowInstanceof.ts, 22, 12)) +>s : Symbol(s, Decl(ts.ts, 22, 12)) } } function f4(s: Set | Set) { ->f4 : Symbol(f4, Decl(controlFlowInstanceof.ts, 30, 1)) ->s : Symbol(s, Decl(controlFlowInstanceof.ts, 32, 12)) +>f4 : Symbol(f4, Decl(ts.ts, 30, 1)) +>s : Symbol(s, Decl(ts.ts, 32, 12)) >Set : Symbol(Set, Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) >Set : Symbol(Set, Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) s = new Set(); ->s : Symbol(s, Decl(controlFlowInstanceof.ts, 32, 12)) +>s : Symbol(s, Decl(ts.ts, 32, 12)) >Set : Symbol(Set, Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) s; // Set ->s : Symbol(s, Decl(controlFlowInstanceof.ts, 32, 12)) +>s : Symbol(s, Decl(ts.ts, 32, 12)) if (s instanceof Set) { ->s : Symbol(s, Decl(controlFlowInstanceof.ts, 32, 12)) +>s : Symbol(s, Decl(ts.ts, 32, 12)) >Set : Symbol(Set, Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) s; // Set ->s : Symbol(s, Decl(controlFlowInstanceof.ts, 32, 12)) +>s : Symbol(s, Decl(ts.ts, 32, 12)) } else { s; // never ->s : Symbol(s, Decl(controlFlowInstanceof.ts, 32, 12)) +>s : Symbol(s, Decl(ts.ts, 32, 12)) } } // More tests class A { a: string } ->A : Symbol(A, Decl(controlFlowInstanceof.ts, 41, 1)) ->a : Symbol(A.a, Decl(controlFlowInstanceof.ts, 45, 9)) +>A : Symbol(A, Decl(ts.ts, 41, 1)) +>a : Symbol(A.a, Decl(ts.ts, 45, 9)) class B extends A { b: string } ->B : Symbol(B, Decl(controlFlowInstanceof.ts, 45, 21)) ->A : Symbol(A, Decl(controlFlowInstanceof.ts, 41, 1)) ->b : Symbol(B.b, Decl(controlFlowInstanceof.ts, 46, 19)) +>B : Symbol(B, Decl(ts.ts, 45, 21)) +>A : Symbol(A, Decl(ts.ts, 41, 1)) +>b : Symbol(B.b, Decl(ts.ts, 46, 19)) class C extends A { c: string } ->C : Symbol(C, Decl(controlFlowInstanceof.ts, 46, 31)) ->A : Symbol(A, Decl(controlFlowInstanceof.ts, 41, 1)) ->c : Symbol(C.c, Decl(controlFlowInstanceof.ts, 47, 19)) +>C : Symbol(C, Decl(ts.ts, 46, 31)) +>A : Symbol(A, Decl(ts.ts, 41, 1)) +>c : Symbol(C.c, Decl(ts.ts, 47, 19)) function foo(x: A | undefined) { ->foo : Symbol(foo, Decl(controlFlowInstanceof.ts, 47, 31)) ->x : Symbol(x, Decl(controlFlowInstanceof.ts, 49, 13)) ->A : Symbol(A, Decl(controlFlowInstanceof.ts, 41, 1)) +>foo : Symbol(foo, Decl(ts.ts, 47, 31)) +>x : Symbol(x, Decl(ts.ts, 49, 13)) +>A : Symbol(A, Decl(ts.ts, 41, 1)) x; // A | undefined ->x : Symbol(x, Decl(controlFlowInstanceof.ts, 49, 13)) +>x : Symbol(x, Decl(ts.ts, 49, 13)) if (x instanceof B || x instanceof C) { ->x : Symbol(x, Decl(controlFlowInstanceof.ts, 49, 13)) ->B : Symbol(B, Decl(controlFlowInstanceof.ts, 45, 21)) ->x : Symbol(x, Decl(controlFlowInstanceof.ts, 49, 13)) ->C : Symbol(C, Decl(controlFlowInstanceof.ts, 46, 31)) +>x : Symbol(x, Decl(ts.ts, 49, 13)) +>B : Symbol(B, Decl(ts.ts, 45, 21)) +>x : Symbol(x, Decl(ts.ts, 49, 13)) +>C : Symbol(C, Decl(ts.ts, 46, 31)) x; // B | C ->x : Symbol(x, Decl(controlFlowInstanceof.ts, 49, 13)) +>x : Symbol(x, Decl(ts.ts, 49, 13)) } x; // A | undefined ->x : Symbol(x, Decl(controlFlowInstanceof.ts, 49, 13)) +>x : Symbol(x, Decl(ts.ts, 49, 13)) if (x instanceof B && x instanceof C) { ->x : Symbol(x, Decl(controlFlowInstanceof.ts, 49, 13)) ->B : Symbol(B, Decl(controlFlowInstanceof.ts, 45, 21)) ->x : Symbol(x, Decl(controlFlowInstanceof.ts, 49, 13)) ->C : Symbol(C, Decl(controlFlowInstanceof.ts, 46, 31)) +>x : Symbol(x, Decl(ts.ts, 49, 13)) +>B : Symbol(B, Decl(ts.ts, 45, 21)) +>x : Symbol(x, Decl(ts.ts, 49, 13)) +>C : Symbol(C, Decl(ts.ts, 46, 31)) x; // B & C ->x : Symbol(x, Decl(controlFlowInstanceof.ts, 49, 13)) +>x : Symbol(x, Decl(ts.ts, 49, 13)) } x; // A | undefined ->x : Symbol(x, Decl(controlFlowInstanceof.ts, 49, 13)) +>x : Symbol(x, Decl(ts.ts, 49, 13)) if (!x) { ->x : Symbol(x, Decl(controlFlowInstanceof.ts, 49, 13)) +>x : Symbol(x, Decl(ts.ts, 49, 13)) return; } x; // A ->x : Symbol(x, Decl(controlFlowInstanceof.ts, 49, 13)) +>x : Symbol(x, Decl(ts.ts, 49, 13)) if (x instanceof B) { ->x : Symbol(x, Decl(controlFlowInstanceof.ts, 49, 13)) ->B : Symbol(B, Decl(controlFlowInstanceof.ts, 45, 21)) +>x : Symbol(x, Decl(ts.ts, 49, 13)) +>B : Symbol(B, Decl(ts.ts, 45, 21)) x; // B ->x : Symbol(x, Decl(controlFlowInstanceof.ts, 49, 13)) +>x : Symbol(x, Decl(ts.ts, 49, 13)) if (x instanceof C) { ->x : Symbol(x, Decl(controlFlowInstanceof.ts, 49, 13)) ->C : Symbol(C, Decl(controlFlowInstanceof.ts, 46, 31)) +>x : Symbol(x, Decl(ts.ts, 49, 13)) +>C : Symbol(C, Decl(ts.ts, 46, 31)) x; // B & C ->x : Symbol(x, Decl(controlFlowInstanceof.ts, 49, 13)) +>x : Symbol(x, Decl(ts.ts, 49, 13)) } else { x; // B ->x : Symbol(x, Decl(controlFlowInstanceof.ts, 49, 13)) +>x : Symbol(x, Decl(ts.ts, 49, 13)) } x; // B ->x : Symbol(x, Decl(controlFlowInstanceof.ts, 49, 13)) +>x : Symbol(x, Decl(ts.ts, 49, 13)) } else { x; // A ->x : Symbol(x, Decl(controlFlowInstanceof.ts, 49, 13)) +>x : Symbol(x, Decl(ts.ts, 49, 13)) } x; // A ->x : Symbol(x, Decl(controlFlowInstanceof.ts, 49, 13)) +>x : Symbol(x, Decl(ts.ts, 49, 13)) } // X is neither assignable to Y nor a subtype of Y // Y is assignable to X, but not a subtype of X interface X { ->X : Symbol(X, Decl(controlFlowInstanceof.ts, 77, 1)) +>X : Symbol(X, Decl(ts.ts, 77, 1)) x?: string; ->x : Symbol(X.x, Decl(controlFlowInstanceof.ts, 82, 13)) +>x : Symbol(X.x, Decl(ts.ts, 82, 13)) } class Y { ->Y : Symbol(Y, Decl(controlFlowInstanceof.ts, 84, 1)) +>Y : Symbol(Y, Decl(ts.ts, 84, 1)) y: string; ->y : Symbol(Y.y, Decl(controlFlowInstanceof.ts, 86, 9)) +>y : Symbol(Y.y, Decl(ts.ts, 86, 9)) } function goo(x: X) { ->goo : Symbol(goo, Decl(controlFlowInstanceof.ts, 88, 1)) ->x : Symbol(x, Decl(controlFlowInstanceof.ts, 90, 13)) ->X : Symbol(X, Decl(controlFlowInstanceof.ts, 77, 1)) +>goo : Symbol(goo, Decl(ts.ts, 88, 1)) +>x : Symbol(x, Decl(ts.ts, 90, 13)) +>X : Symbol(X, Decl(ts.ts, 77, 1)) x; ->x : Symbol(x, Decl(controlFlowInstanceof.ts, 90, 13)) +>x : Symbol(x, Decl(ts.ts, 90, 13)) if (x instanceof Y) { ->x : Symbol(x, Decl(controlFlowInstanceof.ts, 90, 13)) ->Y : Symbol(Y, Decl(controlFlowInstanceof.ts, 84, 1)) +>x : Symbol(x, Decl(ts.ts, 90, 13)) +>Y : Symbol(Y, Decl(ts.ts, 84, 1)) x.y; ->x.y : Symbol(Y.y, Decl(controlFlowInstanceof.ts, 86, 9)) ->x : Symbol(x, Decl(controlFlowInstanceof.ts, 90, 13)) ->y : Symbol(Y.y, Decl(controlFlowInstanceof.ts, 86, 9)) +>x.y : Symbol(Y.y, Decl(ts.ts, 86, 9)) +>x : Symbol(x, Decl(ts.ts, 90, 13)) +>y : Symbol(Y.y, Decl(ts.ts, 86, 9)) } x; ->x : Symbol(x, Decl(controlFlowInstanceof.ts, 90, 13)) +>x : Symbol(x, Decl(ts.ts, 90, 13)) } // Repro from #27282 declare const x: (() => void)|null; ->x : Symbol(x, Decl(controlFlowInstanceof.ts, 100, 13)) +>x : Symbol(x, Decl(ts.ts, 100, 13)) declare const ctor: Function; ->ctor : Symbol(ctor, Decl(controlFlowInstanceof.ts, 101, 13)) +>ctor : Symbol(ctor, Decl(ts.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 : Symbol(x, Decl(ts.ts, 100, 13)) +>ctor : Symbol(ctor, Decl(ts.ts, 101, 13)) x(); ->x : Symbol(x, Decl(controlFlowInstanceof.ts, 100, 13)) +>x : Symbol(x, Decl(ts.ts, 100, 13)) +} + +// Repro from #27550 (based on uglify code) +=== tests/cases/compiler/uglify.js === +/** @constructor */ +function AtTop(val) { this.val = val } +>AtTop : Symbol(AtTop, Decl(uglify.js, 0, 0)) +>val : Symbol(val, Decl(uglify.js, 1, 15)) +>this.val : Symbol(AtTop.val, Decl(uglify.js, 1, 21)) +>this : Symbol(AtTop, Decl(uglify.js, 0, 0)) +>val : Symbol(AtTop.val, Decl(uglify.js, 1, 21)) +>val : Symbol(val, Decl(uglify.js, 1, 15)) + +/** @type {*} */ +var v = 1; +>v : Symbol(v, Decl(uglify.js, 3, 3)) + +if (v instanceof AtTop) { +>v : Symbol(v, Decl(uglify.js, 3, 3)) +>AtTop : Symbol(AtTop, Decl(uglify.js, 0, 0)) + + v.val +>v.val : Symbol(AtTop.val, Decl(uglify.js, 1, 21)) +>v : Symbol(v, Decl(uglify.js, 3, 3)) +>val : Symbol(AtTop.val, Decl(uglify.js, 1, 21)) } diff --git a/tests/baselines/reference/controlFlowInstanceof.types b/tests/baselines/reference/controlFlowInstanceof.types index e7c05a4c015a4..a4925746620eb 100644 --- a/tests/baselines/reference/controlFlowInstanceof.types +++ b/tests/baselines/reference/controlFlowInstanceof.types @@ -1,4 +1,4 @@ -=== tests/cases/compiler/controlFlowInstanceof.ts === +=== tests/cases/compiler/ts.ts === // Repros from #10167 function f1(s: Set | Set) { @@ -261,3 +261,31 @@ if (x instanceof ctor) { >x : () => void } +// Repro from #27550 (based on uglify code) +=== tests/cases/compiler/uglify.js === +/** @constructor */ +function AtTop(val) { this.val = val } +>AtTop : typeof AtTop +>val : any +>this.val = val : any +>this.val : any +>this : AtTop +>val : any +>val : any + +/** @type {*} */ +var v = 1; +>v : any +>1 : 1 + +if (v instanceof AtTop) { +>v instanceof AtTop : boolean +>v : any +>AtTop : typeof AtTop + + v.val +>v.val : any +>v : AtTop +>val : any +} + diff --git a/tests/cases/compiler/controlFlowInstanceof.ts b/tests/cases/compiler/controlFlowInstanceof.ts index f9cf844572ff7..6779008d1a62a 100644 --- a/tests/cases/compiler/controlFlowInstanceof.ts +++ b/tests/cases/compiler/controlFlowInstanceof.ts @@ -1,6 +1,10 @@ // @target: es6 +// @noEmit: true +// @allowJs: true +// @checkJs: true // @strictNullChecks: true +// @Filename: ts.ts // Repros from #10167 function f1(s: Set | Set) { @@ -107,3 +111,13 @@ declare const ctor: Function; if (x instanceof ctor) { x(); } + +// Repro from #27550 (based on uglify code) +// @Filename: uglify.js +/** @constructor */ +function AtTop(val) { this.val = val } +/** @type {*} */ +var v = 1; +if (v instanceof AtTop) { + v.val +} From b65492011d92ddd6552628a72a4c94b1203157b7 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Thu, 4 Oct 2018 09:30:23 -0700 Subject: [PATCH 2/3] Rename test filename --- .../reference/controlFlowInstanceof.symbols | 170 +++++++++--------- .../reference/controlFlowInstanceof.types | 2 +- tests/cases/compiler/controlFlowInstanceof.ts | 2 +- 3 files changed, 87 insertions(+), 87 deletions(-) diff --git a/tests/baselines/reference/controlFlowInstanceof.symbols b/tests/baselines/reference/controlFlowInstanceof.symbols index df3c552eb2ea9..2be43d5ef6eee 100644 --- a/tests/baselines/reference/controlFlowInstanceof.symbols +++ b/tests/baselines/reference/controlFlowInstanceof.symbols @@ -1,250 +1,250 @@ -=== tests/cases/compiler/ts.ts === +=== tests/cases/compiler/controlFlowInstanceof.ts === // Repros from #10167 function f1(s: Set | Set) { ->f1 : Symbol(f1, Decl(ts.ts, 0, 0)) ->s : Symbol(s, Decl(ts.ts, 2, 12)) +>f1 : Symbol(f1, Decl(controlFlowInstanceof.ts, 0, 0)) +>s : Symbol(s, Decl(controlFlowInstanceof.ts, 2, 12)) >Set : Symbol(Set, Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) >Set : Symbol(Set, Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) s = new Set(); ->s : Symbol(s, Decl(ts.ts, 2, 12)) +>s : Symbol(s, Decl(controlFlowInstanceof.ts, 2, 12)) >Set : Symbol(Set, Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) s; // Set ->s : Symbol(s, Decl(ts.ts, 2, 12)) +>s : Symbol(s, Decl(controlFlowInstanceof.ts, 2, 12)) if (s instanceof Set) { ->s : Symbol(s, Decl(ts.ts, 2, 12)) +>s : Symbol(s, Decl(controlFlowInstanceof.ts, 2, 12)) >Set : Symbol(Set, Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) s; // Set ->s : Symbol(s, Decl(ts.ts, 2, 12)) +>s : Symbol(s, Decl(controlFlowInstanceof.ts, 2, 12)) } s; // Set ->s : Symbol(s, Decl(ts.ts, 2, 12)) +>s : Symbol(s, Decl(controlFlowInstanceof.ts, 2, 12)) s.add(42); >s.add : Symbol(Set.add, Decl(lib.es2015.collection.d.ts, --, --)) ->s : Symbol(s, Decl(ts.ts, 2, 12)) +>s : Symbol(s, Decl(controlFlowInstanceof.ts, 2, 12)) >add : Symbol(Set.add, Decl(lib.es2015.collection.d.ts, --, --)) } function f2(s: Set | Set) { ->f2 : Symbol(f2, Decl(ts.ts, 10, 1)) ->s : Symbol(s, Decl(ts.ts, 12, 12)) +>f2 : Symbol(f2, Decl(controlFlowInstanceof.ts, 10, 1)) +>s : Symbol(s, Decl(controlFlowInstanceof.ts, 12, 12)) >Set : Symbol(Set, Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) >Set : Symbol(Set, Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) s = new Set(); ->s : Symbol(s, Decl(ts.ts, 12, 12)) +>s : Symbol(s, Decl(controlFlowInstanceof.ts, 12, 12)) >Set : Symbol(Set, Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) s; // Set ->s : Symbol(s, Decl(ts.ts, 12, 12)) +>s : Symbol(s, Decl(controlFlowInstanceof.ts, 12, 12)) if (s instanceof Promise) { ->s : Symbol(s, Decl(ts.ts, 12, 12)) +>s : Symbol(s, Decl(controlFlowInstanceof.ts, 12, 12)) >Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) s; // Set & Promise ->s : Symbol(s, Decl(ts.ts, 12, 12)) +>s : Symbol(s, Decl(controlFlowInstanceof.ts, 12, 12)) } s; // Set ->s : Symbol(s, Decl(ts.ts, 12, 12)) +>s : Symbol(s, Decl(controlFlowInstanceof.ts, 12, 12)) s.add(42); >s.add : Symbol(Set.add, Decl(lib.es2015.collection.d.ts, --, --)) ->s : Symbol(s, Decl(ts.ts, 12, 12)) +>s : Symbol(s, Decl(controlFlowInstanceof.ts, 12, 12)) >add : Symbol(Set.add, Decl(lib.es2015.collection.d.ts, --, --)) } function f3(s: Set | Set) { ->f3 : Symbol(f3, Decl(ts.ts, 20, 1)) ->s : Symbol(s, Decl(ts.ts, 22, 12)) +>f3 : Symbol(f3, Decl(controlFlowInstanceof.ts, 20, 1)) +>s : Symbol(s, Decl(controlFlowInstanceof.ts, 22, 12)) >Set : Symbol(Set, Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) >Set : Symbol(Set, Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) s; // Set | Set ->s : Symbol(s, Decl(ts.ts, 22, 12)) +>s : Symbol(s, Decl(controlFlowInstanceof.ts, 22, 12)) if (s instanceof Set) { ->s : Symbol(s, Decl(ts.ts, 22, 12)) +>s : Symbol(s, Decl(controlFlowInstanceof.ts, 22, 12)) >Set : Symbol(Set, Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) s; // Set | Set ->s : Symbol(s, Decl(ts.ts, 22, 12)) +>s : Symbol(s, Decl(controlFlowInstanceof.ts, 22, 12)) } else { s; // never ->s : Symbol(s, Decl(ts.ts, 22, 12)) +>s : Symbol(s, Decl(controlFlowInstanceof.ts, 22, 12)) } } function f4(s: Set | Set) { ->f4 : Symbol(f4, Decl(ts.ts, 30, 1)) ->s : Symbol(s, Decl(ts.ts, 32, 12)) +>f4 : Symbol(f4, Decl(controlFlowInstanceof.ts, 30, 1)) +>s : Symbol(s, Decl(controlFlowInstanceof.ts, 32, 12)) >Set : Symbol(Set, Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) >Set : Symbol(Set, Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) s = new Set(); ->s : Symbol(s, Decl(ts.ts, 32, 12)) +>s : Symbol(s, Decl(controlFlowInstanceof.ts, 32, 12)) >Set : Symbol(Set, Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) s; // Set ->s : Symbol(s, Decl(ts.ts, 32, 12)) +>s : Symbol(s, Decl(controlFlowInstanceof.ts, 32, 12)) if (s instanceof Set) { ->s : Symbol(s, Decl(ts.ts, 32, 12)) +>s : Symbol(s, Decl(controlFlowInstanceof.ts, 32, 12)) >Set : Symbol(Set, Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) s; // Set ->s : Symbol(s, Decl(ts.ts, 32, 12)) +>s : Symbol(s, Decl(controlFlowInstanceof.ts, 32, 12)) } else { s; // never ->s : Symbol(s, Decl(ts.ts, 32, 12)) +>s : Symbol(s, Decl(controlFlowInstanceof.ts, 32, 12)) } } // More tests class A { a: string } ->A : Symbol(A, Decl(ts.ts, 41, 1)) ->a : Symbol(A.a, Decl(ts.ts, 45, 9)) +>A : Symbol(A, Decl(controlFlowInstanceof.ts, 41, 1)) +>a : Symbol(A.a, Decl(controlFlowInstanceof.ts, 45, 9)) class B extends A { b: string } ->B : Symbol(B, Decl(ts.ts, 45, 21)) ->A : Symbol(A, Decl(ts.ts, 41, 1)) ->b : Symbol(B.b, Decl(ts.ts, 46, 19)) +>B : Symbol(B, Decl(controlFlowInstanceof.ts, 45, 21)) +>A : Symbol(A, Decl(controlFlowInstanceof.ts, 41, 1)) +>b : Symbol(B.b, Decl(controlFlowInstanceof.ts, 46, 19)) class C extends A { c: string } ->C : Symbol(C, Decl(ts.ts, 46, 31)) ->A : Symbol(A, Decl(ts.ts, 41, 1)) ->c : Symbol(C.c, Decl(ts.ts, 47, 19)) +>C : Symbol(C, Decl(controlFlowInstanceof.ts, 46, 31)) +>A : Symbol(A, Decl(controlFlowInstanceof.ts, 41, 1)) +>c : Symbol(C.c, Decl(controlFlowInstanceof.ts, 47, 19)) function foo(x: A | undefined) { ->foo : Symbol(foo, Decl(ts.ts, 47, 31)) ->x : Symbol(x, Decl(ts.ts, 49, 13)) ->A : Symbol(A, Decl(ts.ts, 41, 1)) +>foo : Symbol(foo, Decl(controlFlowInstanceof.ts, 47, 31)) +>x : Symbol(x, Decl(controlFlowInstanceof.ts, 49, 13)) +>A : Symbol(A, Decl(controlFlowInstanceof.ts, 41, 1)) x; // A | undefined ->x : Symbol(x, Decl(ts.ts, 49, 13)) +>x : Symbol(x, Decl(controlFlowInstanceof.ts, 49, 13)) if (x instanceof B || x instanceof C) { ->x : Symbol(x, Decl(ts.ts, 49, 13)) ->B : Symbol(B, Decl(ts.ts, 45, 21)) ->x : Symbol(x, Decl(ts.ts, 49, 13)) ->C : Symbol(C, Decl(ts.ts, 46, 31)) +>x : Symbol(x, Decl(controlFlowInstanceof.ts, 49, 13)) +>B : Symbol(B, Decl(controlFlowInstanceof.ts, 45, 21)) +>x : Symbol(x, Decl(controlFlowInstanceof.ts, 49, 13)) +>C : Symbol(C, Decl(controlFlowInstanceof.ts, 46, 31)) x; // B | C ->x : Symbol(x, Decl(ts.ts, 49, 13)) +>x : Symbol(x, Decl(controlFlowInstanceof.ts, 49, 13)) } x; // A | undefined ->x : Symbol(x, Decl(ts.ts, 49, 13)) +>x : Symbol(x, Decl(controlFlowInstanceof.ts, 49, 13)) if (x instanceof B && x instanceof C) { ->x : Symbol(x, Decl(ts.ts, 49, 13)) ->B : Symbol(B, Decl(ts.ts, 45, 21)) ->x : Symbol(x, Decl(ts.ts, 49, 13)) ->C : Symbol(C, Decl(ts.ts, 46, 31)) +>x : Symbol(x, Decl(controlFlowInstanceof.ts, 49, 13)) +>B : Symbol(B, Decl(controlFlowInstanceof.ts, 45, 21)) +>x : Symbol(x, Decl(controlFlowInstanceof.ts, 49, 13)) +>C : Symbol(C, Decl(controlFlowInstanceof.ts, 46, 31)) x; // B & C ->x : Symbol(x, Decl(ts.ts, 49, 13)) +>x : Symbol(x, Decl(controlFlowInstanceof.ts, 49, 13)) } x; // A | undefined ->x : Symbol(x, Decl(ts.ts, 49, 13)) +>x : Symbol(x, Decl(controlFlowInstanceof.ts, 49, 13)) if (!x) { ->x : Symbol(x, Decl(ts.ts, 49, 13)) +>x : Symbol(x, Decl(controlFlowInstanceof.ts, 49, 13)) return; } x; // A ->x : Symbol(x, Decl(ts.ts, 49, 13)) +>x : Symbol(x, Decl(controlFlowInstanceof.ts, 49, 13)) if (x instanceof B) { ->x : Symbol(x, Decl(ts.ts, 49, 13)) ->B : Symbol(B, Decl(ts.ts, 45, 21)) +>x : Symbol(x, Decl(controlFlowInstanceof.ts, 49, 13)) +>B : Symbol(B, Decl(controlFlowInstanceof.ts, 45, 21)) x; // B ->x : Symbol(x, Decl(ts.ts, 49, 13)) +>x : Symbol(x, Decl(controlFlowInstanceof.ts, 49, 13)) if (x instanceof C) { ->x : Symbol(x, Decl(ts.ts, 49, 13)) ->C : Symbol(C, Decl(ts.ts, 46, 31)) +>x : Symbol(x, Decl(controlFlowInstanceof.ts, 49, 13)) +>C : Symbol(C, Decl(controlFlowInstanceof.ts, 46, 31)) x; // B & C ->x : Symbol(x, Decl(ts.ts, 49, 13)) +>x : Symbol(x, Decl(controlFlowInstanceof.ts, 49, 13)) } else { x; // B ->x : Symbol(x, Decl(ts.ts, 49, 13)) +>x : Symbol(x, Decl(controlFlowInstanceof.ts, 49, 13)) } x; // B ->x : Symbol(x, Decl(ts.ts, 49, 13)) +>x : Symbol(x, Decl(controlFlowInstanceof.ts, 49, 13)) } else { x; // A ->x : Symbol(x, Decl(ts.ts, 49, 13)) +>x : Symbol(x, Decl(controlFlowInstanceof.ts, 49, 13)) } x; // A ->x : Symbol(x, Decl(ts.ts, 49, 13)) +>x : Symbol(x, Decl(controlFlowInstanceof.ts, 49, 13)) } // X is neither assignable to Y nor a subtype of Y // Y is assignable to X, but not a subtype of X interface X { ->X : Symbol(X, Decl(ts.ts, 77, 1)) +>X : Symbol(X, Decl(controlFlowInstanceof.ts, 77, 1)) x?: string; ->x : Symbol(X.x, Decl(ts.ts, 82, 13)) +>x : Symbol(X.x, Decl(controlFlowInstanceof.ts, 82, 13)) } class Y { ->Y : Symbol(Y, Decl(ts.ts, 84, 1)) +>Y : Symbol(Y, Decl(controlFlowInstanceof.ts, 84, 1)) y: string; ->y : Symbol(Y.y, Decl(ts.ts, 86, 9)) +>y : Symbol(Y.y, Decl(controlFlowInstanceof.ts, 86, 9)) } function goo(x: X) { ->goo : Symbol(goo, Decl(ts.ts, 88, 1)) ->x : Symbol(x, Decl(ts.ts, 90, 13)) ->X : Symbol(X, Decl(ts.ts, 77, 1)) +>goo : Symbol(goo, Decl(controlFlowInstanceof.ts, 88, 1)) +>x : Symbol(x, Decl(controlFlowInstanceof.ts, 90, 13)) +>X : Symbol(X, Decl(controlFlowInstanceof.ts, 77, 1)) x; ->x : Symbol(x, Decl(ts.ts, 90, 13)) +>x : Symbol(x, Decl(controlFlowInstanceof.ts, 90, 13)) if (x instanceof Y) { ->x : Symbol(x, Decl(ts.ts, 90, 13)) ->Y : Symbol(Y, Decl(ts.ts, 84, 1)) +>x : Symbol(x, Decl(controlFlowInstanceof.ts, 90, 13)) +>Y : Symbol(Y, Decl(controlFlowInstanceof.ts, 84, 1)) x.y; ->x.y : Symbol(Y.y, Decl(ts.ts, 86, 9)) ->x : Symbol(x, Decl(ts.ts, 90, 13)) ->y : Symbol(Y.y, Decl(ts.ts, 86, 9)) +>x.y : Symbol(Y.y, Decl(controlFlowInstanceof.ts, 86, 9)) +>x : Symbol(x, Decl(controlFlowInstanceof.ts, 90, 13)) +>y : Symbol(Y.y, Decl(controlFlowInstanceof.ts, 86, 9)) } x; ->x : Symbol(x, Decl(ts.ts, 90, 13)) +>x : Symbol(x, Decl(controlFlowInstanceof.ts, 90, 13)) } // Repro from #27282 declare const x: (() => void)|null; ->x : Symbol(x, Decl(ts.ts, 100, 13)) +>x : Symbol(x, Decl(controlFlowInstanceof.ts, 100, 13)) declare const ctor: Function; ->ctor : Symbol(ctor, Decl(ts.ts, 101, 13)) +>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(ts.ts, 100, 13)) ->ctor : Symbol(ctor, Decl(ts.ts, 101, 13)) +>x : Symbol(x, Decl(controlFlowInstanceof.ts, 100, 13)) +>ctor : Symbol(ctor, Decl(controlFlowInstanceof.ts, 101, 13)) x(); ->x : Symbol(x, Decl(ts.ts, 100, 13)) +>x : Symbol(x, Decl(controlFlowInstanceof.ts, 100, 13)) } // Repro from #27550 (based on uglify code) diff --git a/tests/baselines/reference/controlFlowInstanceof.types b/tests/baselines/reference/controlFlowInstanceof.types index a4925746620eb..9aa38025a1cab 100644 --- a/tests/baselines/reference/controlFlowInstanceof.types +++ b/tests/baselines/reference/controlFlowInstanceof.types @@ -1,4 +1,4 @@ -=== tests/cases/compiler/ts.ts === +=== tests/cases/compiler/controlFlowInstanceof.ts === // Repros from #10167 function f1(s: Set | Set) { diff --git a/tests/cases/compiler/controlFlowInstanceof.ts b/tests/cases/compiler/controlFlowInstanceof.ts index 6779008d1a62a..b032fb708dc58 100644 --- a/tests/cases/compiler/controlFlowInstanceof.ts +++ b/tests/cases/compiler/controlFlowInstanceof.ts @@ -4,7 +4,7 @@ // @checkJs: true // @strictNullChecks: true -// @Filename: ts.ts +// @Filename: controlFlowInstanceof.ts // Repros from #10167 function f1(s: Set | Set) { From 055405b32e49305c980bac9b65cbbb8d9c6ecbea Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Thu, 4 Oct 2018 12:56:07 -0700 Subject: [PATCH 3/3] Fix whitespace lint --- src/compiler/checker.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 160570c424759..2b1d7648d85ef 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -15392,7 +15392,7 @@ namespace ts { if (!targetType) { let constructSignatures = getSignaturesOfType(rightType, SignatureKind.Construct); - if(constructSignatures.length === 0) { + if (constructSignatures.length === 0) { constructSignatures = filter(getSignaturesOfType(rightType, SignatureKind.Call), sig => isJSConstructor(sig.declaration)); } targetType = constructSignatures.length ?