File: widenedTypes.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 (51 lines) | stat: -rw-r--r-- 2,549 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
tests/cases/compiler/widenedTypes.ts(1,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(4,1): error TS18050: The value 'null' cannot be used here.
tests/cases/compiler/widenedTypes.ts(5,7): error TS18050: The value 'null' cannot be used here.
tests/cases/compiler/widenedTypes.ts(9,14): error TS2695: Left side of comma operator is unused and has no side effects.
tests/cases/compiler/widenedTypes.ts(10,1): error TS2322: Type 'string' is not assignable to type 'number'.
tests/cases/compiler/widenedTypes.ts(17,1): error TS2322: Type 'string' is not assignable to type 'number'.
tests/cases/compiler/widenedTypes.ts(22,22): error TS2322: Type 'number' is not assignable to type 'string'.
tests/cases/compiler/widenedTypes.ts(23,39): error TS2322: 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 {};
    ~~~~
!!! error TS18050: The value 'null' cannot be used here.
    "" in null;
          ~~~~
!!! error TS18050: The value 'null' cannot be used here.
    
    for (var a in null) { }
    
    var t = [3, (3, null)];
                 ~
!!! error TS2695: Left side of comma operator is unused and has no side effects.
    t[3] = "";
    ~~~~
!!! error TS2322: Type 'string' 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 'string' 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'.
    var obj: { [x: string]: string; } = { x: 3, y: null }; // assignable because null is widened, and therefore BCT is any
                                          ~
!!! error TS2322: Type 'number' is not assignable to type 'string'.
!!! related TS6501 tests/cases/compiler/widenedTypes.ts:23:12: The expected type comes from this index signature.