File: widenedTypes.errors.txt

package info (click to toggle)
node-typescript 2.1.5-1~bpo8%2B1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-backports
  • size: 203,960 kB
  • sloc: sh: 11; makefile: 5
file content (57 lines) | stat: -rw-r--r-- 3,101 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
52
53
54
55
56
57
tests/cases/compiler/widenedTypes.ts(2,1): error TS2358: The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter.
tests/cases/compiler/widenedTypes.ts(6,7): error TS2361: The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter
tests/cases/compiler/widenedTypes.ts(8,15): error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter.
tests/cases/compiler/widenedTypes.ts(10,14): error TS2695: Left side of comma operator is unused and has no side effects.
tests/cases/compiler/widenedTypes.ts(11,1): error TS2322: Type '""' is not assignable to type 'number'.
tests/cases/compiler/widenedTypes.ts(18,1): error TS2322: Type '""' is not assignable to type 'number'.
tests/cases/compiler/widenedTypes.ts(23,5): error TS2322: Type 'number[]' is not assignable to type 'string[]'.
  Type 'number' is not assignable to type 'string'.
tests/cases/compiler/widenedTypes.ts(24,5): error TS2322: Type '{ x: number; y: null; }' is not assignable to type '{ [x: string]: string; }'.
  Property 'x' is incompatible with index signature.
    Type 'number' is not assignable to type 'string'.


==== tests/cases/compiler/widenedTypes.ts (8 errors) ====
    
    null instanceof (() => { });
    ~~~~
!!! error TS2358: The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter.
    ({}) instanceof null; // Ok because null is a subtype of function
    
    null in {};
    "" in null;
          ~~~~
!!! error TS2361: The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter
    
    for (var a in null) { }
                  ~~~~
!!! error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter.
    
    var t = [3, (3, null)];
                 ~
!!! error TS2695: Left side of comma operator is unused and has no side effects.
    t[3] = "";
    ~~~~
!!! error TS2322: Type '""' is not assignable to type 'number'.
    
    var x: typeof undefined = 3;
    x = 3;
    
    var y;
    var u = [3, (y = null)];
    u[3] = "";
    ~~~~
!!! error TS2322: Type '""' is not assignable to type 'number'.
    
    var ob: { x: typeof undefined } = { x: "" };
    
    // Highlights the difference between array literals and object literals
    var arr: string[] = [3, null]; // not assignable because null is not widened. BCT is {}
        ~~~
!!! error TS2322: Type 'number[]' is not assignable to type 'string[]'.
!!! error TS2322:   Type 'number' is not assignable to type 'string'.
    var obj: { [x: string]: string; } = { x: 3, y: null }; // assignable because null is widened, and therefore BCT is any
        ~~~
!!! error TS2322: Type '{ x: number; y: null; }' is not assignable to type '{ [x: string]: string; }'.
!!! error TS2322:   Property 'x' is incompatible with index signature.
!!! error TS2322:     Type 'number' is not assignable to type 'string'.