To me match feels more declarative, we aren't checking the internal representation of the RemoteData value, only providing handlers for all the cases. And since it is function call, it is an expression, wheres switch is a statement.
Eg. going from this to using switch would require quite some boilerplate code.
It's true that TypeScript can do exhaustiveness check on the switch statement. But that requires either to add a default case with a never assertion, or to be in a context where we have to return something in all the branches.
Eg. in a case like this, the switch would produce no error but the match would.
To me
matchfeels more declarative, we aren't checking the internal representation of the RemoteData value, only providing handlers for all the cases. And since it is function call, it is an expression, wheresswitchis a statement.Eg. going from this to using
switchwould require quite some boilerplate code.It's true that TypeScript can do exhaustiveness check on the
switchstatement. But that requires either to add adefaultcase with a never assertion, or to be in a context where we have to return something in all the branches.Eg. in a case like this, the
switchwould produce no error but thematchwould.Ultimately, I think it's a matter of personal preference, based on what are the priorities and what the team feels more comfortable with.