Files
tsgo/testdata/baselines/reference/submodule/conformance/classConstructorParametersAccessibility2.errors.txt

35 lines
1.0 KiB
Plaintext

classConstructorParametersAccessibility2.ts(12,4): error TS2341: Property 'p' is private and only accessible within class 'C2'.
classConstructorParametersAccessibility2.ts(19,4): error TS2445: Property 'p' is protected and only accessible within class 'C3' and its subclasses.
==== classConstructorParametersAccessibility2.ts (2 errors) ====
class C1 {
constructor(public x?: number) { }
}
declare var c1: C1;
c1.x // OK
class C2 {
constructor(private p?: number) { }
}
declare var c2: C2;
c2.p // private, error
~
!!! error TS2341: Property 'p' is private and only accessible within class 'C2'.
class C3 {
constructor(protected p?: number) { }
}
declare var c3: C3;
c3.p // protected, error
~
!!! error TS2445: Property 'p' is protected and only accessible within class 'C3' and its subclasses.
class Derived extends C3 {
constructor(p: number) {
super(p);
this.p; // OK
}
}