Y
Hacker News
new
|
ask
|
show
|
jobs
by
gwillz
2290 days ago
Is this something typescript could fix? I've written a fair few union types with discriminants that work in the same way as rust enums.
The trick though is to declare the redundant fields as undefined for every overlap case.
1 comments
_bxg1
2290 days ago
Possibly. I've had trouble getting TypeScript to discriminate object unions in the past without manually writing type guards, which are cumbersome. This is one of the few things Flow is actually better at.
link