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
|
//// [privateVisibility.ts]
class Foo {
public pubMeth() {this.privMeth();}
private privMeth() {}
public pubProp = 0;
private privProp = 0;
}
var f = new Foo();
f.privMeth(); // should not work
f.privProp; // should not work
f.pubMeth(); // should work
f.pubProp; // should work
module M {
export class C { public pub = 0; private priv = 1; }
export var V = 0;
}
var c = new M.C();
c.pub; // should work
c.priv; // should not work
//// [privateVisibility.js]
var Foo = /** @class */ (function () {
function Foo() {
this.pubProp = 0;
this.privProp = 0;
}
Foo.prototype.pubMeth = function () { this.privMeth(); };
Foo.prototype.privMeth = function () { };
return Foo;
}());
var f = new Foo();
f.privMeth(); // should not work
f.privProp; // should not work
f.pubMeth(); // should work
f.pubProp; // should work
var M;
(function (M) {
var C = /** @class */ (function () {
function C() {
this.pub = 0;
this.priv = 1;
}
return C;
}());
M.C = C;
M.V = 0;
})(M || (M = {}));
var c = new M.C();
c.pub; // should work
c.priv; // should not work
|