Open
Description
75% of my union usage in TS is
void method(data: A | B)
As the proposal says, intersection is hard, so maybe for now Dart could avoid data.something
where something exists in both A and B.
But... Just having A | B in the parameter and being able to switch between them would be extremely helpful for me!! I hate using dynamic or object. And I hate using a second variable that's not null when the first one is.
So, this would be extremely helpful to me:
int method(data: A | B) =>
switch(data) {
A: return 1,
B: return 2,
}
Yet I hear "is" is really really expensive. So maybe this is faster than comparing by "is" twice.
Any thoughts?
I'm not sure opening an issue is the correct path, just wanted to contribute to the discussion.