File: arraySigChecking.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 (50 lines) | stat: -rw-r--r-- 1,783 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
tests/cases/compiler/arraySigChecking.ts(11,17): error TS1023: An index signature parameter type must be 'string' or 'number'.
tests/cases/compiler/arraySigChecking.ts(18,5): error TS2322: Type 'void[]' is not assignable to type 'string[]'.
  Type 'void' is not assignable to type 'string'.
tests/cases/compiler/arraySigChecking.ts(22,1): error TS2322: Type 'number[][]' is not assignable to type 'number[][][]'.
  Type 'number[]' is not assignable to type 'number[][]'.
    Type 'number' is not assignable to type 'number[]'.


==== tests/cases/compiler/arraySigChecking.ts (3 errors) ====
    declare module M {
        interface iBar { t: any; }
        interface iFoo extends iBar {
            s: any;
        }
    
        class cFoo {
            t: any;
        }
    
        var foo: { [index: any]; }; // expect an error here
                    ~~~~~
!!! error TS1023: An index signature parameter type must be 'string' or 'number'.
    }
    
    interface myInt {
        voidFn(): void;
    }
    var myVar: myInt;
    var strArray: string[] = [myVar.voidFn()];
        ~~~~~~~~
!!! error TS2322: Type 'void[]' is not assignable to type 'string[]'.
!!! error TS2322:   Type 'void' is not assignable to type 'string'.
    
    
    var myArray: number[][][];
    myArray = [[1, 2]];
    ~~~~~~~
!!! error TS2322: Type 'number[][]' is not assignable to type 'number[][][]'.
!!! error TS2322:   Type 'number[]' is not assignable to type 'number[][]'.
!!! error TS2322:     Type 'number' is not assignable to type 'number[]'.
    
    function isEmpty(l: { length: number }) {
        return l.length === 0;
    }
    
    isEmpty([]);
    isEmpty(new Array(3));
    isEmpty(new Array<string>(3));
    isEmpty(['a']);