File: derivedClassTransitivity4.errors.txt

package info (click to toggle)
node-typescript 2.1.5-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 203,952 kB
  • ctags: 52,987
  • sloc: sh: 11; makefile: 5
file content (37 lines) | stat: -rw-r--r-- 1,726 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
27
28
29
30
31
32
33
34
35
36
37
tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassTransitivity4.ts(18,1): error TS2322: Type 'E' is not assignable to type 'C'.
  Types of property 'foo' are incompatible.
    Type '(x?: string) => void' is not assignable to type '(x: number) => void'.
      Types of parameters 'x' and 'x' are incompatible.
        Type 'number' is not assignable to type 'string'.
tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassTransitivity4.ts(19,11): error TS2445: Property 'foo' is protected and only accessible within class 'C' and its subclasses.


==== tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassTransitivity4.ts (2 errors) ====
    // subclassing is not transitive when you can remove required parameters and add optional parameters on protected members
    
    class C {
        protected foo(x: number) { }
    }
    
    class D extends C {
        protected foo() { } // ok to drop parameters
    }
    
    class E extends D {
        public foo(x?: string) { } // ok to add optional parameters
    }
    
    var c: C;
    var d: D;
    var e: E;
    c = e;
    ~
!!! error TS2322: Type 'E' is not assignable to type 'C'.
!!! error TS2322:   Types of property 'foo' are incompatible.
!!! error TS2322:     Type '(x?: string) => void' is not assignable to type '(x: number) => void'.
!!! error TS2322:       Types of parameters 'x' and 'x' are incompatible.
!!! error TS2322:         Type 'number' is not assignable to type 'string'.
    var r = c.foo(1);
              ~~~
!!! error TS2445: Property 'foo' is protected and only accessible within class 'C' and its subclasses.
    var r2 = e.foo('');