67 lines
4.9 KiB
Plaintext
67 lines
4.9 KiB
Plaintext
|
tests/cases/conformance/classes/members/accessibility/protectedStaticClassPropertyAccessibleWithinSubclass.ts(7,9): error TS2445: Property 'x' is protected and only accessible within class 'Derived3' and its subclasses.
|
||
|
tests/cases/conformance/classes/members/accessibility/protectedStaticClassPropertyAccessibleWithinSubclass.ts(16,9): error TS2445: Property 'x' is protected and only accessible within class 'Derived3' and its subclasses.
|
||
|
tests/cases/conformance/classes/members/accessibility/protectedStaticClassPropertyAccessibleWithinSubclass.ts(25,9): error TS2445: Property 'x' is protected and only accessible within class 'Derived3' and its subclasses.
|
||
|
tests/cases/conformance/classes/members/accessibility/protectedStaticClassPropertyAccessibleWithinSubclass.ts(40,1): error TS2445: Property 'x' is protected and only accessible within class 'Base' and its subclasses.
|
||
|
tests/cases/conformance/classes/members/accessibility/protectedStaticClassPropertyAccessibleWithinSubclass.ts(41,1): error TS2445: Property 'x' is protected and only accessible within class 'Base' and its subclasses.
|
||
|
tests/cases/conformance/classes/members/accessibility/protectedStaticClassPropertyAccessibleWithinSubclass.ts(42,1): error TS2445: Property 'x' is protected and only accessible within class 'Base' and its subclasses.
|
||
|
tests/cases/conformance/classes/members/accessibility/protectedStaticClassPropertyAccessibleWithinSubclass.ts(43,1): 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.
|