38 lines
1.3 KiB
Plaintext
38 lines
1.3 KiB
Plaintext
tests/cases/compiler/privateVisibility.ts(9,1): error TS2341: Property 'privMeth' is private and only accessible within class 'Foo'.
|
|
tests/cases/compiler/privateVisibility.ts(10,1): error TS2341: Property 'privProp' is private and only accessible within class 'Foo'.
|
|
tests/cases/compiler/privateVisibility.ts(24,1): error TS2341: Property 'priv' is private and only accessible within class 'C'.
|
|
|
|
|
|
==== tests/cases/compiler/privateVisibility.ts (3 errors) ====
|
|
class Foo {
|
|
public pubMeth() {this.privMeth();}
|
|
private privMeth() {}
|
|
public pubProp = 0;
|
|
private privProp = 0;
|
|
}
|
|
|
|
var f = new Foo();
|
|
f.privMeth(); // should not work
|
|
~~~~~~~~~~
|
|
!!! error TS2341: Property 'privMeth' is private and only accessible within class 'Foo'.
|
|
f.privProp; // should not work
|
|
~~~~~~~~~~
|
|
!!! error TS2341: Property 'privProp' is private and only accessible within class 'Foo'.
|
|
|
|
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
|
|
~~~~~~
|
|
!!! error TS2341: Property 'priv' is private and only accessible within class 'C'.
|
|
|
|
|