File: enumLiteralAssignableToEnumInsideUnion.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 (47 lines) | stat: -rw-r--r-- 2,074 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
tests/cases/compiler/enumLiteralAssignableToEnumInsideUnion.ts(24,7): error TS2322: Type 'Foo.A' is not assignable to type 'boolean | Foo'.
tests/cases/compiler/enumLiteralAssignableToEnumInsideUnion.ts(25,7): error TS2322: Type 'Foo.A' is not assignable to type 'boolean | Foo'.
tests/cases/compiler/enumLiteralAssignableToEnumInsideUnion.ts(26,7): error TS2322: Type 'Foo.A' is not assignable to type 'boolean | Foo.B'.
tests/cases/compiler/enumLiteralAssignableToEnumInsideUnion.ts(27,7): error TS2322: Type 'Foo.A' is not assignable to type 'boolean | Foo.A'.
tests/cases/compiler/enumLiteralAssignableToEnumInsideUnion.ts(28,7): error TS2322: Type 'Foo.A' is not assignable to type 'boolean | Foo'.


==== tests/cases/compiler/enumLiteralAssignableToEnumInsideUnion.ts (5 errors) ====
    module X {
        export enum Foo {
            A, B
        }
    }
    module Y {
        export enum Foo {
            A, B
        }
    }
    module Z {
        export enum Foo {
            A = 1 << 1,
            B = 1 << 2,
        }
    }
    module Ka {
        export enum Foo {
            A = 1 << 10,
            B = 1 << 11,
        }
    }
    const e0: X.Foo | boolean = Y.Foo.A; // ok
    const e1: X.Foo | boolean = Z.Foo.A; // not legal, Z is computed
          ~~
!!! error TS2322: Type 'Foo.A' is not assignable to type 'boolean | Foo'.
    const e2: X.Foo.A | X.Foo.B | boolean = Z.Foo.A; // still not legal
          ~~
!!! error TS2322: Type 'Foo.A' is not assignable to type 'boolean | Foo'.
    const e3: X.Foo.B | boolean = Z.Foo.A; // not legal
          ~~
!!! error TS2322: Type 'Foo.A' is not assignable to type 'boolean | Foo.B'.
    const e4: X.Foo.A | boolean = Z.Foo.A; // not legal either because Z.Foo is computed and Z.Foo.A is not necessarily assignable to X.Foo.A
          ~~
!!! error TS2322: Type 'Foo.A' is not assignable to type 'boolean | Foo.A'.
    const e5: Ka.Foo | boolean = Z.Foo.A; // ok
          ~~
!!! error TS2322: Type 'Foo.A' is not assignable to type 'boolean | Foo'.