Bug Report
π Search Terms
Conversion may be a mistake enum unification object literal as
π Version & Regression Information
- This is a crash
- This changed between versions 4.9 and 5.0
β― Playground Link
Playground link with relevant code
π» Code
enum Foo {
None = +0,
A = 1,
B = 2,
C = 4,
}
interface UsesFoo {
foo: Foo;
}
const x = {
foo: 7
} as UsesFoo;
const y: UsesFoo = {
foo: 7
};
π Actual behavior
There's an error on the first assignment and no error on the second assignment.
π Expected behavior
Probably, no errors on either? Or something consistent?
This is a method suggested by https://devblogs.microsoft.com/typescript/announcing-typescript-4-3/#union-enums-cannot-be-compared-to-arbitrary-numbers (and I minimized this from OWA).