File: overloadingOnConstants1.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 (48 lines) | stat: -rw-r--r-- 2,403 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
tests/cases/compiler/overloadingOnConstants1.ts(22,5): error TS2322: Type 'Base' is not assignable to type 'Derived1'.
  Property 'bar' is missing in type 'Base'.
tests/cases/compiler/overloadingOnConstants1.ts(23,5): error TS2322: Type 'Derived1' is not assignable to type 'Derived3'.
  Property 'biz' is missing in type 'Derived1'.
tests/cases/compiler/overloadingOnConstants1.ts(24,5): error TS2322: Type 'Derived2' is not assignable to type 'Derived1'.
  Property 'bar' is missing in type 'Derived2'.
tests/cases/compiler/overloadingOnConstants1.ts(25,5): error TS2322: Type 'Derived3' is not assignable to type 'Derived1'.
  Property 'bar' is missing in type 'Derived3'.


==== tests/cases/compiler/overloadingOnConstants1.ts (4 errors) ====
    class Base { foo() { } }
    class Derived1 extends Base { bar() { } }
    class Derived2 extends Base { baz() { } }
    class Derived3 extends Base { biz() { } }
    
    interface Document2 {
        createElement(tagName: 'canvas'): Derived1;
        createElement(tagName: 'div'): Derived2;
        createElement(tagName: 'span'): Derived3;
        createElement(tagName: string): Base;
    }
    
    var d2: Document2;
    
    // these are ok
    var htmlElement: Base = d2.createElement("yo")
    var htmlCanvasElement: Derived1 = d2.createElement("canvas");
    var htmlDivElement: Derived2 = d2.createElement("div");
    var htmlSpanElement: Derived3 = d2.createElement("span");
    
    // these are errors
    var htmlElement2: Derived1 = d2.createElement("yo")
        ~~~~~~~~~~~~
!!! error TS2322: Type 'Base' is not assignable to type 'Derived1'.
!!! error TS2322:   Property 'bar' is missing in type 'Base'.
    var htmlCanvasElement2: Derived3 = d2.createElement("canvas");
        ~~~~~~~~~~~~~~~~~~
!!! error TS2322: Type 'Derived1' is not assignable to type 'Derived3'.
!!! error TS2322:   Property 'biz' is missing in type 'Derived1'.
    var htmlDivElement2: Derived1 = d2.createElement("div");
        ~~~~~~~~~~~~~~~
!!! error TS2322: Type 'Derived2' is not assignable to type 'Derived1'.
!!! error TS2322:   Property 'bar' is missing in type 'Derived2'.
    var htmlSpanElement2: Derived1 = d2.createElement("span");
        ~~~~~~~~~~~~~~~~
!!! error TS2322: Type 'Derived3' is not assignable to type 'Derived1'.
!!! error TS2322:   Property 'bar' is missing in type 'Derived3'.