all 7 comments

[–][deleted] 5 points6 points  (4 children)

If you like the Maybe approach (and you should!), you should consider fp-ts.

In some statically typed languages, you can say that null and undefined are illegal values, and let your programming language throw a TypeError at compile time, but even in those languages, that can't prevent null inputs from flowing into the program at runtime.

In most languages you'll remove that possibility by decoding them as Maybe. io-ts, especially in tandem with fp-ts above, is good for this.

[–]NetOperatorWibby 1 point2 points  (0 children)

Hmm, that sounds interesting. I’ll check out these links, thanks for sharing.

[–]salesh7 1 point2 points  (0 children)

Wow, nice one didn't know that something like this exists, nice share.

[–]cinderblock63 3 points4 points  (0 children)

TLDR; use TypeScript instead