File: interfaceInheritance.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 (67 lines) | stat: -rw-r--r-- 2,268 bytes parent folder | download | duplicates (2)
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
tests/cases/compiler/interfaceInheritance.ts(22,7): error TS2420: Class 'C1' incorrectly implements interface 'I2'.
  Property 'i1P1' is missing in type 'C1'.
tests/cases/compiler/interfaceInheritance.ts(30,1): error TS2322: Type 'I3' is not assignable to type 'I2'.
  Property 'i1P1' is missing in type 'I3'.
tests/cases/compiler/interfaceInheritance.ts(37,1): error TS2322: Type 'I5' is not assignable to type 'I4'.
  Types of property 'one' are incompatible.
    Type 'string' is not assignable to type 'number'.
tests/cases/compiler/interfaceInheritance.ts(38,1): error TS2322: Type 'I4' is not assignable to type 'I5'.
  Types of property 'one' are incompatible.
    Type 'number' is not assignable to type 'string'.


==== tests/cases/compiler/interfaceInheritance.ts (4 errors) ====
    interface I1 {
        i1P1: number;
        i1P2(): void;
    }
    
    interface I2 extends I1 {
        i2P1: string;
    }
    
    interface I3 {
        i2P1: string; // has a member from i2P1, but not from I1
    }
    
    interface I4 {
    	one: number;
    }
    
    interface I5 {
    	one: string;
    }
    
    class C1 implements I2 { // should be an error - it doesn't implement the members of I1
          ~~
!!! error TS2420: Class 'C1' incorrectly implements interface 'I2'.
!!! error TS2420:   Property 'i1P1' is missing in type 'C1'.
        public i2P1: string;
    }
    
    var i2: I2;
    var i1: I1;
    var i3: I3;
    i1 = i2;
    i2 = i3; // should be an error - i3 does not implement the members of i1
    ~~
!!! error TS2322: Type 'I3' is not assignable to type 'I2'.
!!! error TS2322:   Property 'i1P1' is missing in type 'I3'.
    
    var c1: C1;
    
    var i4: I4;
    var i5: I5;
    
    i4 = i5; // should be an error
    ~~
!!! error TS2322: Type 'I5' is not assignable to type 'I4'.
!!! error TS2322:   Types of property 'one' are incompatible.
!!! error TS2322:     Type 'string' is not assignable to type 'number'.
    i5 = i4; // should be an error
    ~~
!!! error TS2322: Type 'I4' is not assignable to type 'I5'.
!!! error TS2322:   Types of property 'one' are incompatible.
!!! error TS2322:     Type 'number' is not assignable to type 'string'.