File: assignmentCompatWithOverloads.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 (61 lines) | stat: -rw-r--r-- 2,863 bytes parent folder | download | duplicates (4)
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
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 construct signatures are incompatible.
    Type 'new (x: string) => 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 construct signatures are incompatible.
!!! error TS2322:     Type 'new (x: string) => 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'.