3 ms·
One thing I like about typescript is that unless you’re a masochist, it basically pushes you towards option 1. If you have to constantly check for null/undefin
by Waterluvian 3y ago
One thing I like about typescript is that unless you’re a masochist, it basically pushes you towards option 1.
If you have to constantly check for null/undefined it gets annoying and you naturally think about narrowing the state space so entire sections of your program don’t have to think about those possible states.
It should also become obvious when you have a possible null/undefined state and it’s super unclear what that piece of your program ought to do about it other than alert the parent (such as throwing an error). If a component doesn’t have a role to play when null, maybe it shouldn’t ever be seeing null as a possible state.