File: enumLiteralAssignableToEnumInsideUnion.errors.txt

package info (click to toggle)
node-typescript 2.1.5-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 203,952 kB
  • ctags: 52,987
  • sloc: sh: 11; makefile: 5
file content (44 lines) | stat: -rw-r--r-- 1,828 bytes parent folder | download | duplicates (6)
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
tests/cases/compiler/enumLiteralAssignableToEnumInsideUnion.ts(24,7): error TS2322: Type 'Foo' is not assignable to type 'boolean | Foo'.
tests/cases/compiler/enumLiteralAssignableToEnumInsideUnion.ts(25,7): error TS2322: Type 'Foo' is not assignable to type 'boolean | Foo'.
tests/cases/compiler/enumLiteralAssignableToEnumInsideUnion.ts(26,7): error TS2322: Type 'Foo' is not assignable to type 'boolean | Foo.B'.
tests/cases/compiler/enumLiteralAssignableToEnumInsideUnion.ts(27,7): error TS2322: Type 'Foo' is not assignable to type 'boolean | Foo.A'.


==== tests/cases/compiler/enumLiteralAssignableToEnumInsideUnion.ts (4 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' 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' is not assignable to type 'boolean | Foo'.
    const e3: X.Foo.B | boolean = Z.Foo.A; // not legal
          ~~
!!! error TS2322: Type 'Foo' 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' is not assignable to type 'boolean | Foo.A'.
    const e5: Ka.Foo | boolean = Z.Foo.A; // ok