Modeling a Value with Possible Errors in TypeScript
I'm curious how best to model this, i.e. if there are any built-in types to model "a value, with maybe some errors"
I have a cache of all the data my frontend has loaded:
In particular, I want to model this so it's easy to "merge in" the results of the next fetch:
I could probably force it with a Tuple or discriminated union or just simply
I have a cache of all the data my frontend has loaded:
In particular, I want to model this so it's easy to "merge in" the results of the next fetch:
I could probably force it with a Tuple or discriminated union or just simply
{ value: A, error: Option<E> }, and just implement all this pseudocode... but I suspect that the correct choice of types will simplify this a lot