From 6e149dd019f25faa3f5b817f7b638cc2ad6480a9 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Wed, 5 Apr 2017 11:06:40 -0700 Subject: [PATCH] Update baselines --- .../anonymousClassExpression2.errors.txt | 24 +++++++++++ .../reference/anonymousClassExpression2.js | 43 +++++++++++++++++++ .../reference/narrowedConstInMethod.js | 13 +++--- .../reference/narrowedConstInMethod.symbols | 24 ++++++----- .../reference/narrowedConstInMethod.types | 10 +++-- 5 files changed, 94 insertions(+), 20 deletions(-) create mode 100644 tests/baselines/reference/anonymousClassExpression2.errors.txt create mode 100644 tests/baselines/reference/anonymousClassExpression2.js diff --git a/tests/baselines/reference/anonymousClassExpression2.errors.txt b/tests/baselines/reference/anonymousClassExpression2.errors.txt new file mode 100644 index 00000000000..c9b59ae9c4d --- /dev/null +++ b/tests/baselines/reference/anonymousClassExpression2.errors.txt @@ -0,0 +1,24 @@ +tests/cases/compiler/anonymousClassExpression2.ts(13,18): error TS2339: Property 'methodA' does not exist on type 'B'. + + +==== tests/cases/compiler/anonymousClassExpression2.ts (1 errors) ==== + // Fixes #14860 + // note: repros with `while (0);` too + // but it's less inscrutable and more obvious to put it *inside* the loop + while (0) { + class A { + methodA() { + this; //note: a this reference of some kind is required to trigger the bug + } + } + + class B { + methodB() { + this.methodA; // error + ~~~~~~~ +!!! error TS2339: Property 'methodA' does not exist on type 'B'. + this.methodB; // ok + } + } + } + \ No newline at end of file diff --git a/tests/baselines/reference/anonymousClassExpression2.js b/tests/baselines/reference/anonymousClassExpression2.js new file mode 100644 index 00000000000..a1da8d5fb10 --- /dev/null +++ b/tests/baselines/reference/anonymousClassExpression2.js @@ -0,0 +1,43 @@ +//// [anonymousClassExpression2.ts] +// Fixes #14860 +// note: repros with `while (0);` too +// but it's less inscrutable and more obvious to put it *inside* the loop +while (0) { + class A { + methodA() { + this; //note: a this reference of some kind is required to trigger the bug + } + } + + class B { + methodB() { + this.methodA; // error + this.methodB; // ok + } + } +} + + +//// [anonymousClassExpression2.js] +// Fixes #14860 +// note: repros with `while (0);` too +// but it's less inscrutable and more obvious to put it *inside* the loop +while (0) { + var A = (function () { + function A() { + } + A.prototype.methodA = function () { + this; //note: a this reference of some kind is required to trigger the bug + }; + return A; + }()); + var B = (function () { + function B() { + } + B.prototype.methodB = function () { + this.methodA; // error + this.methodB; // ok + }; + return B; + }()); +} diff --git a/tests/baselines/reference/narrowedConstInMethod.js b/tests/baselines/reference/narrowedConstInMethod.js index e2bd1c1cd21..e86b6df6a46 100644 --- a/tests/baselines/reference/narrowedConstInMethod.js +++ b/tests/baselines/reference/narrowedConstInMethod.js @@ -1,9 +1,10 @@ //// [narrowedConstInMethod.ts] +// Fixes #10501, possibly null 'x' function f() { const x: string | null = {}; if (x !== null) { return { - bar() { return x.length; } // Error: possibly null x + bar() { return x.length; } // ok }; } } @@ -12,17 +13,19 @@ function f2() { const x: string | null = {}; if (x !== null) { return class { - bar() { return x.length; } // Error: possibly null x + bar() { return x.length; } // ok }; } -} +} + //// [narrowedConstInMethod.js] +// Fixes #10501, possibly null 'x' function f() { var x = {}; if (x !== null) { return { - bar: function () { return x.length; } // Error: possibly null x + bar: function () { return x.length; } // ok }; } } @@ -32,7 +35,7 @@ function f2() { return (function () { function class_1() { } - class_1.prototype.bar = function () { return x.length; }; // Error: possibly null x + class_1.prototype.bar = function () { return x.length; }; // ok return class_1; }()); } diff --git a/tests/baselines/reference/narrowedConstInMethod.symbols b/tests/baselines/reference/narrowedConstInMethod.symbols index f16837bf1bd..75f8620d19c 100644 --- a/tests/baselines/reference/narrowedConstInMethod.symbols +++ b/tests/baselines/reference/narrowedConstInMethod.symbols @@ -1,18 +1,19 @@ === tests/cases/compiler/narrowedConstInMethod.ts === +// Fixes #10501, possibly null 'x' function f() { >f : Symbol(f, Decl(narrowedConstInMethod.ts, 0, 0)) const x: string | null = {}; ->x : Symbol(x, Decl(narrowedConstInMethod.ts, 1, 9)) +>x : Symbol(x, Decl(narrowedConstInMethod.ts, 2, 9)) if (x !== null) { ->x : Symbol(x, Decl(narrowedConstInMethod.ts, 1, 9)) +>x : Symbol(x, Decl(narrowedConstInMethod.ts, 2, 9)) return { - bar() { return x.length; } // Error: possibly null x ->bar : Symbol(bar, Decl(narrowedConstInMethod.ts, 3, 16)) + bar() { return x.length; } // ok +>bar : Symbol(bar, Decl(narrowedConstInMethod.ts, 4, 16)) >x.length : Symbol(String.length, Decl(lib.d.ts, --, --)) ->x : Symbol(x, Decl(narrowedConstInMethod.ts, 1, 9)) +>x : Symbol(x, Decl(narrowedConstInMethod.ts, 2, 9)) >length : Symbol(String.length, Decl(lib.d.ts, --, --)) }; @@ -20,21 +21,22 @@ function f() { } function f2() { ->f2 : Symbol(f2, Decl(narrowedConstInMethod.ts, 7, 1)) +>f2 : Symbol(f2, Decl(narrowedConstInMethod.ts, 8, 1)) const x: string | null = {}; ->x : Symbol(x, Decl(narrowedConstInMethod.ts, 10, 9)) +>x : Symbol(x, Decl(narrowedConstInMethod.ts, 11, 9)) if (x !== null) { ->x : Symbol(x, Decl(narrowedConstInMethod.ts, 10, 9)) +>x : Symbol(x, Decl(narrowedConstInMethod.ts, 11, 9)) return class { - bar() { return x.length; } // Error: possibly null x ->bar : Symbol((Anonymous class).bar, Decl(narrowedConstInMethod.ts, 12, 22)) + bar() { return x.length; } // ok +>bar : Symbol((Anonymous class).bar, Decl(narrowedConstInMethod.ts, 13, 22)) >x.length : Symbol(String.length, Decl(lib.d.ts, --, --)) ->x : Symbol(x, Decl(narrowedConstInMethod.ts, 10, 9)) +>x : Symbol(x, Decl(narrowedConstInMethod.ts, 11, 9)) >length : Symbol(String.length, Decl(lib.d.ts, --, --)) }; } } + diff --git a/tests/baselines/reference/narrowedConstInMethod.types b/tests/baselines/reference/narrowedConstInMethod.types index 1f3886cc588..9fa0c12473f 100644 --- a/tests/baselines/reference/narrowedConstInMethod.types +++ b/tests/baselines/reference/narrowedConstInMethod.types @@ -1,4 +1,5 @@ === tests/cases/compiler/narrowedConstInMethod.ts === +// Fixes #10501, possibly null 'x' function f() { >f : () => { bar(): number; } | undefined @@ -14,9 +15,9 @@ function f() { >null : null return { ->{ bar() { return x.length; } // Error: possibly null x } : { bar(): number; } +>{ bar() { return x.length; } // ok } : { bar(): number; } - bar() { return x.length; } // Error: possibly null x + bar() { return x.length; } // ok >bar : () => number >x.length : number >x : string @@ -41,9 +42,9 @@ function f2() { >null : null return class { ->class { bar() { return x.length; } // Error: possibly null x } : typeof (Anonymous class) +>class { bar() { return x.length; } // ok } : typeof (Anonymous class) - bar() { return x.length; } // Error: possibly null x + bar() { return x.length; } // ok >bar : () => number >x.length : number >x : string @@ -52,3 +53,4 @@ function f2() { }; } } +