File: interfaceDeclaration3.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 (75 lines) | stat: -rw-r--r-- 2,649 bytes parent folder | download | duplicates (5)
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
tests/cases/compiler/interfaceDeclaration3.ts(7,16): error TS2416: Property 'item' in type 'C1' is not assignable to the same property in base type 'I1'.
  Type 'number' is not assignable to type 'string'.
tests/cases/compiler/interfaceDeclaration3.ts(32,16): error TS2416: Property 'item' in type 'C1' is not assignable to the same property in base type 'I1'.
  Type 'number' is not assignable to type 'string'.
tests/cases/compiler/interfaceDeclaration3.ts(54,11): error TS2430: Interface 'I2' incorrectly extends interface 'I1'.
  Types of property 'item' are incompatible.
    Type 'string' is not assignable to type 'number'.


==== tests/cases/compiler/interfaceDeclaration3.ts (3 errors) ====
    interface I1 { item:number; }
    
    module M1 {
        interface I1 { item:string; }  
        interface I2 { item:number; }   
        class C1 implements I1 {
            public item:number;
                   ~~~~
!!! error TS2416: Property 'item' in type 'C1' is not assignable to the same property in base type 'I1'.
!!! error TS2416:   Type 'number' is not assignable to type 'string'.
        }
        class C2 implements I1 {
            public item:string;
        }
        class C3 implements I2 {
            public item:number;
        }
        
        class C4 implements M2.I1 { 
            public item:string;
        }
    
        class C5 implements M2.M3.I1 {
            public item:string;
        }
    }
    
    export module M2 {
        export interface I1 { item:string; }
        export interface I2 { item:string; }
        export module M3 {
            export interface I1 { item:string; }
        }
        class C1 implements I1 {
            public item:number;    
                   ~~~~
!!! error TS2416: Property 'item' in type 'C1' is not assignable to the same property in base type 'I1'.
!!! error TS2416:   Type 'number' is not assignable to type 'string'.
        }
        class C2 implements I1 {
            public item:string;    
        }
        class C3 implements I2 {
            public item:string;    
        }
    }
    
    class C1 implements I1 {
        public item:number;
    }
    
    class C2 implements M2.I1 { 
        public item:string;
    }
    
    class C3 implements M2.M3.I1 {
        public item:string;
    }
    
    interface I2 extends I1 { item:string; }
              ~~
!!! error TS2430: Interface 'I2' incorrectly extends interface 'I1'.
!!! error TS2430:   Types of property 'item' are incompatible.
!!! error TS2430:     Type 'string' is not assignable to type 'number'.