File: controlFlowWhileStatement.errors.txt

package info (click to toggle)
node-typescript 5.0.4%2Bds1-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 459,116 kB
  • sloc: javascript: 1,972,754; makefile: 6; sh: 1
file content (113 lines) | stat: -rw-r--r-- 2,813 bytes parent folder | download
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
tests/cases/conformance/controlFlow/controlFlowWhileStatement.ts(81,12): error TS2365: Operator '>' cannot be applied to types 'string | number' and 'number'.


==== tests/cases/conformance/controlFlow/controlFlowWhileStatement.ts (1 errors) ====
    let cond: boolean;
    function a() {
        let x: string | number;
        x = "";
        while (cond) {
            x; // string
        }
    }
    function b() {
        let x: string | number;
        x = "";
        while (cond) {
            x; // string
            x = 42;
            break;
        }
    }
    function c() {
        let x: string | number;
        x = "";
        while (cond) {
            x; // string
            x = undefined;
            if (typeof x === "string") continue;
            break;
        }
    }
    function d() {
        let x: string | number;
        x = "";
        while (x = x.length) {
            x; // number
            x = "";
        }
    }
    function e() {
        let x: string | number;
        x = "";
        while (cond) {
            x; // string | number
            x = 42;
            x; // number
        }
        x; // string | number
    }
    function f() {
        let x: string | number | boolean | RegExp | Function;
        x = "";
        while (cond) {
            if (cond) {
                x = 42;
                break;
            }
            if (cond) {
                x = true;
                continue;
            }
            x = /a/;
        }
        x; // string | number | boolean | RegExp
    }
    function g() {
        let x: string | number | boolean | RegExp | Function;
        x = "";
        while (true) {
            if (cond) {
                x = 42;
                break;
            }
            if (cond) {
                x = true;
                continue;
            }
            x = /a/;
        }
        x; // number
    }
    function h1() {
        let x: string | number | boolean;
        x = "";
        while (x > 1) {
               ~~~~~
!!! error TS2365: Operator '>' cannot be applied to types 'string | number' and 'number'.
            x; // string | number
            x = 1;
            x; // number
        }
        x; // string | number
    }
    declare function len(s: string | number): number;
    function h2() {
        let x: string | number | boolean;
        x = "";
        while (cond) {
            x = len(x);
            x; // number
        }
        x; // string | number
    }
    function h3() {
        let x: string | number | boolean;
        x = "";
        while (cond) {
            x; // string | number
            x = len(x);
        }
        x; // string | number
    }