Error ------------------------------------------------------------------------------------------------------ test.js:9:3 Cannot cast `x` to `"bar"` because in at least one member of `"baz" | "foo"` [1]: `"baz"` [2] is incompatible with `"bar"` [3]. [incompatible-type] test.js:9:3 9| x as 'bar'; // error ^ [1] References: test.js:4:20 4| declare const x: Enum; ^^^^ [2] test.js:9:8 9| x as 'bar'; // error ^^^^^ [3] Error ----------------------------------------------------------------------------------------------------- test.js:18:5 Cannot compare `Enum` [1] to `"qux"` [2], because `"bar" | "baz" | "foo"` [1] is not a subtype of `"qux"` [2] and `"qux"` [2] is not a subtype of `"bar" | "baz" | "foo"` [1]. In **rare** cases, these types may have overlapping values but lack a subtyping relationship. If that happens, you can cast one side to the union of both types to pass the flow check. [invalid-compare] test.js:18:5 18| case 'qux': // error ^^^^^^^^^^ References: test.js:13:17 13| declare const x: Enum; ^ [1] test.js:18:10 18| case 'qux': // error ^^^^^ [2] Error ----------------------------------------------------------------------------------------------------- test.js:29:5 Cannot compare `Enum` [1] to `"qux"` [2], because `"bar" | "baz" | "foo"` [1] is not a subtype of `"qux"` [2] and `"qux"` [2] is not a subtype of `"bar" | "baz" | "foo"` [1]. In **rare** cases, these types may have overlapping values but lack a subtyping relationship. If that happens, you can cast one side to the union of both types to pass the flow check. [invalid-compare] test.js:29:5 29| case 'qux': // error ^^^^^^^^^^ References: test.js:24:17 24| declare const x: Enum; ^ [1] test.js:29:10 29| case 'qux': // error ^^^^^ [2] Error ----------------------------------------------------------------------------------------------------- test.js:40:3 Cannot cast `x` to `"foo"` because in at least one member of `"baz" | "foo"` [1]: `"baz"` [2] is incompatible with `"foo"` [3]. [incompatible-type] test.js:40:3 40| x as 'foo'; // error ^ [1] References: test.js:35:18 35| declare let x: Enum; ^^^^ [2] test.js:40:8 40| x as 'foo'; // error ^^^^^ [3] Found 4 errors