1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
|
//// [protectedClassPropertyAccessibleWithinClass.ts]
// no errors
class C {
protected x: string;
protected get y() { return this.x; }
protected set y(x) { this.y = this.x; }
protected foo() { return this.foo; }
protected static x: string;
protected static get y() { return this.x; }
protected static set y(x) { this.y = this.x; }
protected static foo() { return this.foo; }
protected static bar() { this.foo(); }
}
// added level of function nesting
class C2 {
protected x: string;
protected get y() { () => this.x; return null; }
protected set y(x) { () => { this.y = this.x; } }
protected foo() { () => this.foo; }
protected static x: string;
protected static get y() { () => this.x; return null; }
protected static set y(x) {
() => { this.y = this.x; }
}
protected static foo() { () => this.foo; }
protected static bar() { () => this.foo(); }
}
//// [protectedClassPropertyAccessibleWithinClass.js]
// no errors
var C = /** @class */ (function () {
function C() {
}
Object.defineProperty(C.prototype, "y", {
get: function () { return this.x; },
set: function (x) { this.y = this.x; },
enumerable: true,
configurable: true
});
C.prototype.foo = function () { return this.foo; };
Object.defineProperty(C, "y", {
get: function () { return this.x; },
set: function (x) { this.y = this.x; },
enumerable: true,
configurable: true
});
C.foo = function () { return this.foo; };
C.bar = function () { this.foo(); };
return C;
}());
// added level of function nesting
var C2 = /** @class */ (function () {
function C2() {
}
Object.defineProperty(C2.prototype, "y", {
get: function () {
var _this = this;
(function () { return _this.x; });
return null;
},
set: function (x) {
var _this = this;
(function () { _this.y = _this.x; });
},
enumerable: true,
configurable: true
});
C2.prototype.foo = function () {
var _this = this;
(function () { return _this.foo; });
};
Object.defineProperty(C2, "y", {
get: function () {
var _this = this;
(function () { return _this.x; });
return null;
},
set: function (x) {
var _this = this;
(function () { _this.y = _this.x; });
},
enumerable: true,
configurable: true
});
C2.foo = function () {
var _this = this;
(function () { return _this.foo; });
};
C2.bar = function () {
var _this = this;
(function () { return _this.foo(); });
};
return C2;
}());
|