35 lines
No EOL
1.2 KiB
Text
35 lines
No EOL
1.2 KiB
Text
tests/cases/conformance/classes/constructorDeclarations/classConstructorParametersAccessibility2.ts(12,1): error TS2341: Property 'p' is private and only accessible within class 'C2'.
|
|
tests/cases/conformance/classes/constructorDeclarations/classConstructorParametersAccessibility2.ts(19,1): error TS2445: Property 'p' is protected and only accessible within class 'C3' and its subclasses.
|
|
|
|
|
|
==== tests/cases/conformance/classes/constructorDeclarations/classConstructorParametersAccessibility2.ts (2 errors) ====
|
|
class C1 {
|
|
constructor(public x?: number) { }
|
|
}
|
|
var c1: C1;
|
|
c1.x // OK
|
|
|
|
|
|
class C2 {
|
|
constructor(private p?: number) { }
|
|
}
|
|
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) { }
|
|
}
|
|
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
|
|
}
|
|
}
|
|
|