File: assignmentCompatWithOverloads.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 (57 lines) | stat: -rw-r--r-- 2,537 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
tests/cases/compiler/assignmentCompatWithOverloads.ts(17,1): error TS2322: Type '(x: string) => string' is not assignable to type '(s1: string) => number'.
  Type 'string' is not assignable to type 'number'.
tests/cases/compiler/assignmentCompatWithOverloads.ts(19,1): error TS2322: Type '(x: number) => number' is not assignable to type '(s1: string) => number'.
  Types of parameters 'x' and 's1' are incompatible.
    Type 'string' is not assignable to type 'number'.
tests/cases/compiler/assignmentCompatWithOverloads.ts(21,1): error TS2322: Type '{ (x: string): string; (x: number): number; }' is not assignable to type '(s1: string) => number'.
  Type 'string' is not assignable to type 'number'.
tests/cases/compiler/assignmentCompatWithOverloads.ts(30,1): error TS2322: Type 'typeof C' is not assignable to type 'new (x: number) => void'.
  Types of parameters 'x' and 'x' are incompatible.
    Type 'number' is not assignable to type 'string'.


==== tests/cases/compiler/assignmentCompatWithOverloads.ts (4 errors) ====
    function f1(x: string): number { return null; }
    
    function f2(x: string): string { return null; }
    
    function f3(x: number): number { return null; }
    
    function f4(x: string): string;
    
    function f4(x: number): number;
    
    function f4(x: any): any { return undefined; }
    
    var g: (s1: string) => number;
    
    g = f1; // OK 
    
    g = f2; // Error
    ~
!!! error TS2322: Type '(x: string) => string' is not assignable to type '(s1: string) => number'.
!!! error TS2322:   Type 'string' is not assignable to type 'number'.
    
    g = f3; // Error
    ~
!!! error TS2322: Type '(x: number) => number' is not assignable to type '(s1: string) => number'.
!!! error TS2322:   Types of parameters 'x' and 's1' are incompatible.
!!! error TS2322:     Type 'string' is not assignable to type 'number'.
    
    g = f4; // Error
    ~
!!! error TS2322: Type '{ (x: string): string; (x: number): number; }' is not assignable to type '(s1: string) => number'.
!!! error TS2322:   Type 'string' is not assignable to type 'number'.
    
    class C {
        constructor(x: string);
    constructor(x: any) {}
    }
    
    var d: new(x: number) => void;
    
    d = C; // Error
    ~
!!! error TS2322: Type 'typeof C' is not assignable to type 'new (x: number) => void'.
!!! error TS2322:   Types of parameters 'x' and 'x' are incompatible.
!!! error TS2322:     Type 'number' is not assignable to type 'string'.