File: overloadingOnConstants2.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 (39 lines) | stat: -rw-r--r-- 1,571 bytes parent folder | download | duplicates (3)
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
tests/cases/compiler/overloadingOnConstants2.ts(9,10): error TS2394: Overload signature is not compatible with function implementation.
tests/cases/compiler/overloadingOnConstants2.ts(15,13): error TS2345: Argument of type '"um"' is not assignable to parameter of type '"bye"'.
tests/cases/compiler/overloadingOnConstants2.ts(19,10): error TS2394: Overload signature is not compatible with function implementation.


==== tests/cases/compiler/overloadingOnConstants2.ts (3 errors) ====
    class C {
       private x = 1;
    }
    class D extends C {}
    class E { 
       private y = 1;
    }
    function foo(x: "hi", items: string[]): D;
    function foo(x: "bye", items: string[]): E;
             ~~~
!!! error TS2394: Overload signature is not compatible with function implementation.
    function foo(x: string, items: string[]): C {
       return null;
    }
    var a: D = foo("hi", []); // D
    var b: E = foo("bye", []); // E 
    var c = foo("um", []); // error
                ~~~~
!!! error TS2345: Argument of type '"um"' is not assignable to parameter of type '"bye"'.
    
    
    //function bar(x: "hi", items: string[]): D;
    function bar(x: "bye", items: string[]): E;
             ~~~
!!! error TS2394: Overload signature is not compatible with function implementation.
    function bar(x: string, items: string[]): C;
    function bar(x: string, items: string[]): C {
       return null;
    }
    
    var d: D = bar("hi", []); // D
    var e: E = bar("bye", []); // E 
    var f: C = bar("um", []); // C