diff --git a/tests/baselines/reference/divergentAccessorsTypes1.errors.txt b/tests/baselines/reference/divergentAccessorsTypes1.errors.txt deleted file mode 100644 index 59f2116c1aecc..0000000000000 --- a/tests/baselines/reference/divergentAccessorsTypes1.errors.txt +++ /dev/null @@ -1,78 +0,0 @@ -tests/cases/compiler/divergentAccessorsTypes1.ts(2,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/divergentAccessorsTypes1.ts(3,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/divergentAccessorsTypes1.ts(8,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/divergentAccessorsTypes1.ts(9,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. - - -==== tests/cases/compiler/divergentAccessorsTypes1.ts (4 errors) ==== - class Test1 { - get foo(): string { return "" } - ~~~ -!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. - set foo(s: string | number) { - ~~~ -!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. - let a = s as string; - let b = s as number; - } - - get bar(): string | number { return "" } - ~~~ -!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. - set bar(s: string | number | boolean) { - ~~~ -!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. - } - } - - interface Test2 { - get foo(): string; - set foo(s: string | number); - - get bar(): string | number; - set bar(s: string | number | boolean); - } - - type Test3 = { - get foo(): string; - set foo(s: string | number); - - get bar(): string | number; - set bar(s: string | number | boolean); - }; - - { - const t = new Test1(); - t.foo = 32; - let m: string = t.foo; - - // See how CFA interacts with out-of-type writes - t.bar = 42; - let n: number = t.bar; - t.bar = false; - let o = t.bar; - } - - { - const t = {} as Test2; - t.foo = 32; - let m: string = t.foo; - - // See how CFA interacts with out-of-type writes - t.bar = 42; - let n: number = t.bar; - t.bar = false; - let o = t.bar; - } - - { - const t = {} as Test3; - t.foo = 32; - let m: string = t.foo; - - // See how CFA interacts with out-of-type writes - t.bar = 42; - let n: number = t.bar; - t.bar = false; - let o = t.bar; - } \ No newline at end of file diff --git a/tests/baselines/reference/divergentAccessorsTypes1.js b/tests/baselines/reference/divergentAccessorsTypes1.js index e7bb4c93245ed..7f76803b1413a 100644 --- a/tests/baselines/reference/divergentAccessorsTypes1.js +++ b/tests/baselines/reference/divergentAccessorsTypes1.js @@ -65,54 +65,43 @@ type Test3 = { //// [divergentAccessorsTypes1.js] "use strict"; -var Test1 = /** @class */ (function () { - function Test1() { +class Test1 { + get foo() { return ""; } + set foo(s) { + let a = s; + let b = s; } - Object.defineProperty(Test1.prototype, "foo", { - get: function () { return ""; }, - set: function (s) { - var a = s; - var b = s; - }, - enumerable: false, - configurable: true - }); - Object.defineProperty(Test1.prototype, "bar", { - get: function () { return ""; }, - set: function (s) { - }, - enumerable: false, - configurable: true - }); - return Test1; -}()); + get bar() { return ""; } + set bar(s) { + } +} { - var t = new Test1(); + const t = new Test1(); t.foo = 32; - var m = t.foo; + let m = t.foo; // See how CFA interacts with out-of-type writes t.bar = 42; - var n = t.bar; + let n = t.bar; t.bar = false; - var o = t.bar; + let o = t.bar; } { - var t = {}; + const t = {}; t.foo = 32; - var m = t.foo; + let m = t.foo; // See how CFA interacts with out-of-type writes t.bar = 42; - var n = t.bar; + let n = t.bar; t.bar = false; - var o = t.bar; + let o = t.bar; } { - var t = {}; + const t = {}; t.foo = 32; - var m = t.foo; + let m = t.foo; // See how CFA interacts with out-of-type writes t.bar = 42; - var n = t.bar; + let n = t.bar; t.bar = false; - var o = t.bar; + let o = t.bar; } diff --git a/tests/baselines/reference/divergentAccessorsVisibility1.errors.txt b/tests/baselines/reference/divergentAccessorsVisibility1.errors.txt index 0941c4d702038..142dbc507fb06 100644 --- a/tests/baselines/reference/divergentAccessorsVisibility1.errors.txt +++ b/tests/baselines/reference/divergentAccessorsVisibility1.errors.txt @@ -1,27 +1,9 @@ -tests/cases/compiler/divergentAccessorsVisibility1.ts(2,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/divergentAccessorsVisibility1.ts(3,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/divergentAccessorsVisibility1.ts(5,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/divergentAccessorsVisibility1.ts(6,19): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/divergentAccessorsVisibility1.ts(8,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/divergentAccessorsVisibility1.ts(9,17): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/divergentAccessorsVisibility1.ts(11,19): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/divergentAccessorsVisibility1.ts(11,19): error TS2798: A get accessor must be at least as accessible as the setter -tests/cases/compiler/divergentAccessorsVisibility1.ts(12,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/divergentAccessorsVisibility1.ts(12,9): error TS2798: A get accessor must be at least as accessible as the setter -tests/cases/compiler/divergentAccessorsVisibility1.ts(14,19): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/divergentAccessorsVisibility1.ts(15,19): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/divergentAccessorsVisibility1.ts(17,19): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/divergentAccessorsVisibility1.ts(18,17): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/divergentAccessorsVisibility1.ts(20,17): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/divergentAccessorsVisibility1.ts(20,17): error TS2798: A get accessor must be at least as accessible as the setter -tests/cases/compiler/divergentAccessorsVisibility1.ts(21,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/divergentAccessorsVisibility1.ts(21,9): error TS2798: A get accessor must be at least as accessible as the setter -tests/cases/compiler/divergentAccessorsVisibility1.ts(23,17): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/divergentAccessorsVisibility1.ts(23,17): error TS2798: A get accessor must be at least as accessible as the setter -tests/cases/compiler/divergentAccessorsVisibility1.ts(24,19): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/divergentAccessorsVisibility1.ts(24,19): error TS2798: A get accessor must be at least as accessible as the setter -tests/cases/compiler/divergentAccessorsVisibility1.ts(26,17): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/divergentAccessorsVisibility1.ts(27,17): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/divergentAccessorsVisibility1.ts(66,14): error TS2341: Property 'PublicPrivate' is private and only accessible within class 'Base'. tests/cases/compiler/divergentAccessorsVisibility1.ts(69,14): error TS2341: Property 'ProtectedPrivate' is private and only accessible within class 'Base'. tests/cases/compiler/divergentAccessorsVisibility1.ts(72,14): error TS2341: Property 'PrivatePrivate' is private and only accessible within class 'Base'. @@ -69,82 +51,46 @@ tests/cases/compiler/divergentAccessorsVisibility1.ts(155,11): error TS2445: Pro tests/cases/compiler/divergentAccessorsVisibility1.ts(156,11): error TS2341: Property 'PrivatePrivate' is private and only accessible within class 'Base'. -==== tests/cases/compiler/divergentAccessorsVisibility1.ts (69 errors) ==== +==== tests/cases/compiler/divergentAccessorsVisibility1.ts (51 errors) ==== class Base { get PublicPublic() { return 0; } - ~~~~~~~~~~~~ -!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. set PublicPublic(v) { return; } - ~~~~~~~~~~~~ -!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. get PublicProtected() { return 0; } - ~~~~~~~~~~~~~~~ -!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. protected set PublicProtected(v) { return; } - ~~~~~~~~~~~~~~~ -!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. get PublicPrivate() { return 0; } - ~~~~~~~~~~~~~ -!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. private set PublicPrivate(v) { return; } - ~~~~~~~~~~~~~ -!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. protected get ProtectedPublic() { return 0; } ~~~~~~~~~~~~~~~ -!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. - ~~~~~~~~~~~~~~~ !!! error TS2798: A get accessor must be at least as accessible as the setter set ProtectedPublic(v) { return; } ~~~~~~~~~~~~~~~ -!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. - ~~~~~~~~~~~~~~~ !!! error TS2798: A get accessor must be at least as accessible as the setter protected get ProtectedProtected() { return 0; } - ~~~~~~~~~~~~~~~~~~ -!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. protected set ProtectedProtected(v) { return; } - ~~~~~~~~~~~~~~~~~~ -!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. protected get ProtectedPrivate() { return 0; } - ~~~~~~~~~~~~~~~~ -!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. private set ProtectedPrivate(v) { return; } - ~~~~~~~~~~~~~~~~ -!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. private get PrivatePublic() { return 0; } ~~~~~~~~~~~~~ -!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. - ~~~~~~~~~~~~~ !!! error TS2798: A get accessor must be at least as accessible as the setter set PrivatePublic(v) { return; } ~~~~~~~~~~~~~ -!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. - ~~~~~~~~~~~~~ !!! error TS2798: A get accessor must be at least as accessible as the setter private get PrivateProtected() { return 0; } ~~~~~~~~~~~~~~~~ -!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. - ~~~~~~~~~~~~~~~~ !!! error TS2798: A get accessor must be at least as accessible as the setter protected set PrivateProtected(v) { return; } ~~~~~~~~~~~~~~~~ -!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. - ~~~~~~~~~~~~~~~~ !!! error TS2798: A get accessor must be at least as accessible as the setter private get PrivatePrivate() { return 0; } - ~~~~~~~~~~~~~~ -!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. private set PrivatePrivate(v) { return; } - ~~~~~~~~~~~~~~ -!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. test() { this.PublicPublic = 0; diff --git a/tests/baselines/reference/divergentAccessorsVisibility1.js b/tests/baselines/reference/divergentAccessorsVisibility1.js index 1a62d22a5cb40..4fab6316e7644 100644 --- a/tests/baselines/reference/divergentAccessorsVisibility1.js +++ b/tests/baselines/reference/divergentAccessorsVisibility1.js @@ -160,79 +160,26 @@ function fn() { //// [divergentAccessorsVisibility1.js] "use strict"; -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - if (typeof b !== "function" && b !== null) - throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -var Base = /** @class */ (function () { - function Base() { - } - Object.defineProperty(Base.prototype, "PublicPublic", { - get: function () { return 0; }, - set: function (v) { return; }, - enumerable: false, - configurable: true - }); - Object.defineProperty(Base.prototype, "PublicProtected", { - get: function () { return 0; }, - set: function (v) { return; }, - enumerable: false, - configurable: true - }); - Object.defineProperty(Base.prototype, "PublicPrivate", { - get: function () { return 0; }, - set: function (v) { return; }, - enumerable: false, - configurable: true - }); - Object.defineProperty(Base.prototype, "ProtectedPublic", { - get: function () { return 0; }, - set: function (v) { return; }, - enumerable: false, - configurable: true - }); - Object.defineProperty(Base.prototype, "ProtectedProtected", { - get: function () { return 0; }, - set: function (v) { return; }, - enumerable: false, - configurable: true - }); - Object.defineProperty(Base.prototype, "ProtectedPrivate", { - get: function () { return 0; }, - set: function (v) { return; }, - enumerable: false, - configurable: true - }); - Object.defineProperty(Base.prototype, "PrivatePublic", { - get: function () { return 0; }, - set: function (v) { return; }, - enumerable: false, - configurable: true - }); - Object.defineProperty(Base.prototype, "PrivateProtected", { - get: function () { return 0; }, - set: function (v) { return; }, - enumerable: false, - configurable: true - }); - Object.defineProperty(Base.prototype, "PrivatePrivate", { - get: function () { return 0; }, - set: function (v) { return; }, - enumerable: false, - configurable: true - }); - Base.prototype.test = function () { +class Base { + get PublicPublic() { return 0; } + set PublicPublic(v) { return; } + get PublicProtected() { return 0; } + set PublicProtected(v) { return; } + get PublicPrivate() { return 0; } + set PublicPrivate(v) { return; } + get ProtectedPublic() { return 0; } + set ProtectedPublic(v) { return; } + get ProtectedProtected() { return 0; } + set ProtectedProtected(v) { return; } + get ProtectedPrivate() { return 0; } + set ProtectedPrivate(v) { return; } + get PrivatePublic() { return 0; } + set PrivatePublic(v) { return; } + get PrivateProtected() { return 0; } + set PrivateProtected(v) { return; } + get PrivatePrivate() { return 0; } + set PrivatePrivate(v) { return; } + test() { this.PublicPublic = 0; this.PublicProtected = 0; this.PublicPrivate = 0; @@ -260,15 +207,10 @@ var Base = /** @class */ (function () { this.PrivatePublic += 0; this.PrivateProtected += 0; this.PrivatePrivate += 0; - }; - return Base; -}()); -var Derived = /** @class */ (function (_super) { - __extends(Derived, _super); - function Derived() { - return _super !== null && _super.apply(this, arguments) || this; } - Derived.prototype.test2 = function () { +} +class Derived extends Base { + test2() { this.PublicPublic = 0; this.PublicProtected = 0; this.PublicPrivate = 0; @@ -296,9 +238,8 @@ var Derived = /** @class */ (function (_super) { this.PrivatePublic += 0; this.PrivateProtected += 0; this.PrivatePrivate += 0; - }; - return Derived; -}(Base)); + } +} function fn() { base.PublicPublic = 0; base.PublicProtected = 0; diff --git a/tests/cases/compiler/divergentAccessorsTypes1.ts b/tests/cases/compiler/divergentAccessorsTypes1.ts index 4c8ddacec1cff..fb3e5c63dd78c 100644 --- a/tests/cases/compiler/divergentAccessorsTypes1.ts +++ b/tests/cases/compiler/divergentAccessorsTypes1.ts @@ -1,5 +1,5 @@ // @strict: true - +// @target: esnext class Test1 { get foo(): string { return "" } diff --git a/tests/cases/compiler/divergentAccessorsVisibility1.ts b/tests/cases/compiler/divergentAccessorsVisibility1.ts index f9e61dbb72a82..2ab11a295d984 100644 --- a/tests/cases/compiler/divergentAccessorsVisibility1.ts +++ b/tests/cases/compiler/divergentAccessorsVisibility1.ts @@ -1,4 +1,5 @@ // @strict: true +// @target: esnext class Base { get PublicPublic() { return 0; }