File: functionAssignment.errors.txt

package info (click to toggle)
node-typescript 3.3.3333-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 324,548 kB
  • sloc: makefile: 6; sh: 3
file content (46 lines) | stat: -rw-r--r-- 1,206 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
tests/cases/compiler/functionAssignment.ts(22,5): error TS2322: Type '4' is not assignable to type 'string'.
tests/cases/compiler/functionAssignment.ts(34,17): error TS2339: Property 'length' does not exist on type 'number'.


==== tests/cases/compiler/functionAssignment.ts (2 errors) ====
    function f(n: Function) { }
    f(function () { });
    
    interface foo {
        get(handler: (bar: number)=>void): void;
    }
    
    interface baz {
        get(callback: Function): number;
    }
    
    var barbaz: baz;
    var test: foo;
    
    test.get(function (param) {
        var x = barbaz.get(function () { });
    });
    
    function f2(n: () => void) { }
    f2(() => {
        var n = '';
        n = 4;
        ~
!!! error TS2322: Type '4' is not assignable to type 'string'.
    });
    
    function f3(a: { a: number; b: number; }) { }
    
    f3({ a: 0, b: 0 });
    
    
    function callb(lam:(l: number) => void );
    function callb(lam:(n: string)=>void);
    function callb(a) { }
    
    callb((a) =>{ a.length; });
                    ~~~~~~
!!! error TS2339: Property 'length' does not exist on type 'number'.