File: equalityWithEnumTypes.errors.txt

package info (click to toggle)
node-typescript 4.9.5%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 533,908 kB
  • sloc: javascript: 2,018,330; makefile: 7; sh: 1
file content (51 lines) | stat: -rw-r--r-- 1,455 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
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 (2 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) {
            v;
        }
        if (v !== 1) {
            v;
        }
        if (v !== 2) {
            v;
        }
        if (v !== 3) {
            v;
        }
    }