DEV Community

Discussion on: Guards using invariant in JS

Collapse
 
assertnotnull profile image
Patrice Gauthier

Dropping a different idea here but using Either in JS or TS with that last link having a good description. It also solves the problem of error bubbling and not knowing if a function will throw an error and you have to handle it since the moment you have an Either, you know there's an error state.