Closed
Description
(TypeScript Version: 2.4.1 stable)
Code
Here is a use case of class expressions that allows access to the private members of the outer class.
fyi: I actually like this behavior, but it is probably a bug.
class classX {
private y: number = 0;
public getY(): number { return this.y; }
public utilities = new class {
constructor(public superThis: classX) {
}
public testSetOuterPrivate(target: number) {
this.superThis.y = target;
}
}(this);
}
const x1: classX = new classX();
alert(x1.getY());
x1.utilities.testSetOuterPrivate(4);
alert(x1.getY());
Expected behavior:
this.superThis.y should blow an access error on compilation
Actual behavior:
this.superThis.y does not blow an access error on compilation