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 59 60 61 62 63 64 65 66 67
|
tests/cases/conformance/classes/members/accessibility/protectedStaticClassPropertyAccessibleWithinSubclass.ts(7,18): error TS2445: Property 'x' is protected and only accessible within class 'Derived3' and its subclasses.
tests/cases/conformance/classes/members/accessibility/protectedStaticClassPropertyAccessibleWithinSubclass.ts(16,18): error TS2445: Property 'x' is protected and only accessible within class 'Derived3' and its subclasses.
tests/cases/conformance/classes/members/accessibility/protectedStaticClassPropertyAccessibleWithinSubclass.ts(25,18): error TS2445: Property 'x' is protected and only accessible within class 'Derived3' and its subclasses.
tests/cases/conformance/classes/members/accessibility/protectedStaticClassPropertyAccessibleWithinSubclass.ts(40,6): error TS2445: Property 'x' is protected and only accessible within class 'Base' and its subclasses.
tests/cases/conformance/classes/members/accessibility/protectedStaticClassPropertyAccessibleWithinSubclass.ts(41,10): error TS2445: Property 'x' is protected and only accessible within class 'Base' and its subclasses.
tests/cases/conformance/classes/members/accessibility/protectedStaticClassPropertyAccessibleWithinSubclass.ts(42,10): error TS2445: Property 'x' is protected and only accessible within class 'Base' and its subclasses.
tests/cases/conformance/classes/members/accessibility/protectedStaticClassPropertyAccessibleWithinSubclass.ts(43,10): error TS2445: Property 'x' is protected and only accessible within class 'Derived3' and its subclasses.
==== tests/cases/conformance/classes/members/accessibility/protectedStaticClassPropertyAccessibleWithinSubclass.ts (7 errors) ====
class Base {
protected static x: string;
static staticMethod() {
Base.x; // OK, accessed within their declaring class
Derived1.x; // OK, accessed within their declaring class
Derived2.x; // OK, accessed within their declaring class
Derived3.x; // Error, redefined in a subclass, can only be accessed in the declaring class or one of its subclasses
~
!!! error TS2445: Property 'x' is protected and only accessible within class 'Derived3' and its subclasses.
}
}
class Derived1 extends Base {
static staticMethod1() {
Base.x; // OK, accessed within a class derived from their declaring class
Derived1.x; // OK, accessed within a class derived from their declaring class
Derived2.x; // OK, accessed within a class derived from their declaring class
Derived3.x; // Error, redefined in a subclass, can only be accessed in the declaring class or one of its subclasses
~
!!! error TS2445: Property 'x' is protected and only accessible within class 'Derived3' and its subclasses.
}
}
class Derived2 extends Base {
static staticMethod2() {
Base.x; // OK, accessed within a class derived from their declaring class
Derived1.x; // OK, accessed within a class derived from their declaring class
Derived2.x; // OK, accessed within a class derived from their declaring class
Derived3.x; // Error, redefined in a subclass, can only be accessed in the declaring class or one of its subclasses
~
!!! error TS2445: Property 'x' is protected and only accessible within class 'Derived3' and its subclasses.
}
}
class Derived3 extends Derived1 {
protected static x: string;
static staticMethod3() {
Base.x; // OK, accessed within a class derived from their declaring class
Derived1.x; // OK, accessed within a class derived from their declaring class
Derived2.x; // OK, accessed within a class derived from their declaring class
Derived3.x; // OK, accessed within their declaring class
}
}
Base.x; // Error, neither within their declaring class nor classes derived from their declaring class
~
!!! error TS2445: Property 'x' is protected and only accessible within class 'Base' and its subclasses.
Derived1.x; // Error, neither within their declaring class nor classes derived from their declaring class
~
!!! error TS2445: Property 'x' is protected and only accessible within class 'Base' and its subclasses.
Derived2.x; // Error, neither within their declaring class nor classes derived from their declaring class
~
!!! error TS2445: Property 'x' is protected and only accessible within class 'Base' and its subclasses.
Derived3.x; // Error, neither within their declaring class nor classes derived from their declaring class
~
!!! error TS2445: Property 'x' is protected and only accessible within class 'Derived3' and its subclasses.
|