File: protectedInstanceMemberAccessibility.errors.txt

package info (click to toggle)
node-typescript 5.0.4%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 459,140 kB
  • sloc: javascript: 1,972,754; makefile: 6; sh: 1
file content (86 lines) | stat: -rw-r--r-- 5,193 bytes parent folder | download | duplicates (3)
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
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,20): error TS2446: Property 'x' is protected and only accessible through an instance of class 'B'. This is an instance of class 'A'.
tests/cases/conformance/classes/members/accessibility/protectedInstanceMemberAccessibility.ts(23,20): error TS2446: Property 'f' is protected and only accessible through an instance of class 'B'. This is an instance of class 'A'.
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,20): error TS2446: Property 'x' is protected and only accessible through an instance of class 'B'. This is an instance of class 'C'.
tests/cases/conformance/classes/members/accessibility/protectedInstanceMemberAccessibility.ts(35,20): error TS2446: Property 'f' is protected and only accessible through an instance of class 'B'. This is an instance of class 'C'.
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,20): 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'. This is an instance of class 'A'.
            var a2 = a.f();  // error
                       ~
!!! error TS2446: Property 'f' is protected and only accessible through an instance of class 'B'. This is an instance of class 'A'.
            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'. This is an instance of class 'C'.
            var c2 = c.f();  // error
                       ~
!!! error TS2446: Property 'f' is protected and only accessible through an instance of class 'B'. This is an instance of class 'C'.
            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;
    }