86 lines
4.8 KiB
Text
86 lines
4.8 KiB
Text
|
tests/cases/conformance/classes/members/accessibility/protectedInstanceMemberAccessibility.ts(14,23): error TS2339: Property 'z' does not exist on type 'B'.
|
||
|
tests/cases/conformance/classes/members/accessibility/protectedInstanceMemberAccessibility.ts(16,24): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword
|
||
|
tests/cases/conformance/classes/members/accessibility/protectedInstanceMemberAccessibility.ts(18,24): error TS2339: Property 'y' does not exist on type 'A'.
|
||
|
tests/cases/conformance/classes/members/accessibility/protectedInstanceMemberAccessibility.ts(19,24): error TS2339: Property 'z' does not exist on type 'A'.
|
||
|
tests/cases/conformance/classes/members/accessibility/protectedInstanceMemberAccessibility.ts(22,18): error TS2446: Property 'x' is protected and only accessible through an instance of class 'B'.
|
||
|
tests/cases/conformance/classes/members/accessibility/protectedInstanceMemberAccessibility.ts(23,18): error TS2446: Property 'f' is protected and only accessible through an instance of class 'B'.
|
||
|
tests/cases/conformance/classes/members/accessibility/protectedInstanceMemberAccessibility.ts(24,20): error TS2339: Property 'y' does not exist on type 'A'.
|
||
|
tests/cases/conformance/classes/members/accessibility/protectedInstanceMemberAccessibility.ts(25,20): error TS2339: Property 'z' does not exist on type 'A'.
|
||
|
tests/cases/conformance/classes/members/accessibility/protectedInstanceMemberAccessibility.ts(31,20): error TS2339: Property 'z' does not exist on type 'B'.
|
||
|
tests/cases/conformance/classes/members/accessibility/protectedInstanceMemberAccessibility.ts(34,18): error TS2446: Property 'x' is protected and only accessible through an instance of class 'B'.
|
||
|
tests/cases/conformance/classes/members/accessibility/protectedInstanceMemberAccessibility.ts(35,18): error TS2446: Property 'f' is protected and only accessible through an instance of class 'B'.
|
||
|
tests/cases/conformance/classes/members/accessibility/protectedInstanceMemberAccessibility.ts(36,20): error TS2339: Property 'y' does not exist on type 'C'.
|
||
|
tests/cases/conformance/classes/members/accessibility/protectedInstanceMemberAccessibility.ts(37,18): error TS2445: Property 'z' is protected and only accessible within class 'C' and its subclasses.
|
||
|
|
||
|
|
||
|
==== tests/cases/conformance/classes/members/accessibility/protectedInstanceMemberAccessibility.ts (13 errors) ====
|
||
|
class A {
|
||
|
protected x: string;
|
||
|
protected f(): string {
|
||
|
return "hello";
|
||
|
}
|
||
|
}
|
||
|
|
||
|
class B extends A {
|
||
|
protected y: string;
|
||
|
g() {
|
||
|
var t1 = this.x;
|
||
|
var t2 = this.f();
|
||
|
var t3 = this.y;
|
||
|
var t4 = this.z; // error
|
||
|
~
|
||
|
!!! error TS2339: Property 'z' does not exist on type 'B'.
|
||
|
|
||
|
var s1 = super.x; // error
|
||
|
~
|
||
|
!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword
|
||
|
var s2 = super.f();
|
||
|
var s3 = super.y; // error
|
||
|
~
|
||
|
!!! error TS2339: Property 'y' does not exist on type 'A'.
|
||
|
var s4 = super.z; // error
|
||
|
~
|
||
|
!!! error TS2339: Property 'z' does not exist on type 'A'.
|
||
|
|
||
|
var a: A;
|
||
|
var a1 = a.x; // error
|
||
|
~~~
|
||
|
!!! error TS2446: Property 'x' is protected and only accessible through an instance of class 'B'.
|
||
|
var a2 = a.f(); // error
|
||
|
~~~
|
||
|
!!! error TS2446: Property 'f' is protected and only accessible through an instance of class 'B'.
|
||
|
var a3 = a.y; // error
|
||
|
~
|
||
|
!!! error TS2339: Property 'y' does not exist on type 'A'.
|
||
|
var a4 = a.z; // error
|
||
|
~
|
||
|
!!! error TS2339: Property 'z' does not exist on type 'A'.
|
||
|
|
||
|
var b: B;
|
||
|
var b1 = b.x;
|
||
|
var b2 = b.f();
|
||
|
var b3 = b.y;
|
||
|
var b4 = b.z; // error
|
||
|
~
|
||
|
!!! error TS2339: Property 'z' does not exist on type 'B'.
|
||
|
|
||
|
var c: C;
|
||
|
var c1 = c.x; // error
|
||
|
~~~
|
||
|
!!! error TS2446: Property 'x' is protected and only accessible through an instance of class 'B'.
|
||
|
var c2 = c.f(); // error
|
||
|
~~~
|
||
|
!!! error TS2446: Property 'f' is protected and only accessible through an instance of class 'B'.
|
||
|
var c3 = c.y; // error
|
||
|
~
|
||
|
!!! error TS2339: Property 'y' does not exist on type 'C'.
|
||
|
var c4 = c.z; // error
|
||
|
~~~
|
||
|
!!! error TS2445: Property 'z' is protected and only accessible within class 'C' and its subclasses.
|
||
|
}
|
||
|
}
|
||
|
|
||
|
class C extends A {
|
||
|
protected z: string;
|
||
|
}
|
||
|
|