File: overloadResolutionTest1.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 (51 lines) | stat: -rw-r--r-- 2,730 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
tests/cases/compiler/overloadResolutionTest1.ts(8,16): error TS2345: Argument of type '{ a: "s"; }[]' is not assignable to parameter of type '{ a: boolean; }[]'.
  Type '{ a: "s"; }' is not assignable to type '{ a: boolean; }'.
    Types of property 'a' are incompatible.
      Type '"s"' is not assignable to type 'boolean'.
tests/cases/compiler/overloadResolutionTest1.ts(19,15): error TS2345: Argument of type '{ a: "s"; }' is not assignable to parameter of type '{ a: boolean; }'.
  Types of property 'a' are incompatible.
    Type '"s"' is not assignable to type 'boolean'.
tests/cases/compiler/overloadResolutionTest1.ts(25,14): error TS2345: Argument of type '{ a: boolean; }' is not assignable to parameter of type '{ a: string; }'.
  Types of property 'a' are incompatible.
    Type 'boolean' is not assignable to type 'string'.


==== tests/cases/compiler/overloadResolutionTest1.ts (3 errors) ====
    
    function foo(bar:{a:number;}[]):string;
    function foo(bar:{a:boolean;}[]):number;
    function foo(bar:{a:any;}[]):any{ return bar };
    
    var x1 = foo([{a:true}]); // works
    var x11 = foo([{a:0}]); // works
    var x111 = foo([{a:"s"}]); // error - does not match any signature
                   ~~~~~~~~~
!!! error TS2345: Argument of type '{ a: "s"; }[]' is not assignable to parameter of type '{ a: boolean; }[]'.
!!! error TS2345:   Type '{ a: "s"; }' is not assignable to type '{ a: boolean; }'.
!!! error TS2345:     Types of property 'a' are incompatible.
!!! error TS2345:       Type '"s"' is not assignable to type 'boolean'.
    var x1111 = foo([{a:null}]); // works - ambiguous call is resolved to be the first in the overload set so this returns a string
    
    
    
    function foo2(bar:{a:number;}):string;
    function foo2(bar:{a:boolean;}):number;
    function foo2(bar:{a:any;}):any{ return bar };
    
    var x2 = foo2({a:0}); // works
    var x3 = foo2({a:true}); // works
    var x4 = foo2({a:"s"}); // error
                  ~~~~~~~
!!! error TS2345: Argument of type '{ a: "s"; }' is not assignable to parameter of type '{ a: boolean; }'.
!!! error TS2345:   Types of property 'a' are incompatible.
!!! error TS2345:     Type '"s"' is not assignable to type 'boolean'.
    
    
    function foo4(bar:{a:number;}):number;
    function foo4(bar:{a:string;}):string;
    function foo4(bar:{a:any;}):any{ return bar };
    var x = foo4({a:true}); // error
                 ~~~~~~~~
!!! error TS2345: Argument of type '{ a: boolean; }' is not assignable to parameter of type '{ a: string; }'.
!!! error TS2345:   Types of property 'a' are incompatible.
!!! error TS2345:     Type 'boolean' is not assignable to type 'string'.