File: interfaceExtendingClassWithProtecteds.errors.txt

package info (click to toggle)
node-typescript 3.3.3333-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 324,548 kB
  • sloc: makefile: 6; sh: 3
file content (26 lines) | stat: -rw-r--r-- 1,155 bytes parent folder | download | duplicates (7)
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
tests/cases/conformance/interfaces/interfacesExtendingClasses/interfaceExtendingClassWithProtecteds.ts(5,11): error TS2430: Interface 'I' incorrectly extends interface 'Foo'.
  Property 'x' is protected but type 'I' is not a class derived from 'Foo'.
tests/cases/conformance/interfaces/interfacesExtendingClasses/interfaceExtendingClassWithProtecteds.ts(15,12): error TS2445: Property 'x' is protected and only accessible within class 'Foo' and its subclasses.


==== tests/cases/conformance/interfaces/interfacesExtendingClasses/interfaceExtendingClassWithProtecteds.ts (2 errors) ====
    class Foo {
        protected x: string;
    }
    
    interface I extends Foo { // error
              ~
!!! error TS2430: Interface 'I' incorrectly extends interface 'Foo'.
!!! error TS2430:   Property 'x' is protected but type 'I' is not a class derived from 'Foo'.
        x: string;
    }
    
    interface I2 extends Foo {
        y: string;
    }
    
    var i: I2;
    var r = i.y;
    var r2 = i.x; // error
               ~
!!! error TS2445: Property 'x' is protected and only accessible within class 'Foo' and its subclasses.