File: equalityWithEnumTypes.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 (57 lines) | stat: -rw-r--r-- 2,115 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
tests/cases/conformance/types/typeRelationships/comparable/equalityWithEnumTypes.ts(14,9): error TS2367: This comparison appears to be unintentional because the types 'E1' and '0' have no overlap.
tests/cases/conformance/types/typeRelationships/comparable/equalityWithEnumTypes.ts(23,9): error TS2367: This comparison appears to be unintentional because the types 'E1' and '3' have no overlap.
tests/cases/conformance/types/typeRelationships/comparable/equalityWithEnumTypes.ts(29,9): error TS2367: This comparison appears to be unintentional because the types 'E2' and '0' have no overlap.
tests/cases/conformance/types/typeRelationships/comparable/equalityWithEnumTypes.ts(38,9): error TS2367: This comparison appears to be unintentional because the types 'E2' and '3' have no overlap.


==== tests/cases/conformance/types/typeRelationships/comparable/equalityWithEnumTypes.ts (4 errors) ====
    // Literal enum type
    enum E1 {
        a = 1,
        b = 2,
    }
    
    // Numeric enum type
    enum E2 {
        a = 1 << 0,
        b = 1 << 1
    }
    
    function f1(v: E1) {
        if (v !== 0) {  // Error
            ~~~~~~~
!!! error TS2367: This comparison appears to be unintentional because the types 'E1' and '0' have no overlap.
            v;
        }
        if (v !== 1) {
            v;
        }
        if (v !== 2) {
            v;
        }
        if (v !== 3) {  // Error
            ~~~~~~~
!!! error TS2367: This comparison appears to be unintentional because the types 'E1' and '3' have no overlap.
            v;
        }
    }
    
    function f2(v: E2) {
        if (v !== 0) {
            ~~~~~~~
!!! error TS2367: This comparison appears to be unintentional because the types 'E2' and '0' have no overlap.
            v;
        }
        if (v !== 1) {
            v;
        }
        if (v !== 2) {
            v;
        }
        if (v !== 3) {
            ~~~~~~~
!!! error TS2367: This comparison appears to be unintentional because the types 'E2' and '3' have no overlap.
            v;
        }
    }