Closed conradreuter closed 3 years ago
When using discriminated unions I noticed something odd:
This works: (Try Flow)
type Config = | {| +kind: typeof Kind.FOO |} | {| +kind: typeof Kind.BAR |} const Kind = Object.freeze({ FOO: ('FOO': 'FOO'), BAR: ('BAR': 'BAR'), }) const fooConfig: Config = {kind: Kind.FOO} const barConfig: Config = {kind: Kind.BAR}
but this gives [speculation-ambiguous]: (Try Flow)
[speculation-ambiguous]
type Config = | {| +kind: typeof Kind.foo |} | {| +kind: typeof Kind.bar |} const Kind = Object.freeze({ foo: ('FOO': 'FOO'), bar: ('BAR': 'BAR'), }) const fooConfig: Config = {kind: Kind.foo} const barConfig: Config = {kind: Kind.bar}
Note that the only difference is in the keys of the Kind object.
Kind
Also note that the keys of Kind don't need to be equal to the values for this to work. (Try Flow)
Please submit your issue to the corresponding project page (https://github.com/facebook/flow ?) Thank you.
When using discriminated unions I noticed something odd:
This works: (Try Flow)
but this gives
[speculation-ambiguous]
: (Try Flow)Note that the only difference is in the keys of the
Kind
object.Also note that the keys of
Kind
don't need to be equal to the values for this to work. (Try Flow)