3 ms·
> Optional chaining or null checks should not be used "defensively" Agreed. I often find the `Uncaught TypeError: Cannot read properties of null` error annoyin
by themanmaran 4y ago
> Optional chaining or null checks should not be used "defensively"
Agreed. I often find the `Uncaught TypeError: Cannot read properties of null` error annoying. But I would rather see the error than let unknown nulls sneak through my codebase.
- bluepnume 4y agoQuite often the best thing to do is: 1. Wait until TS complains about a possible null 2. If you have a good default value, use that instead 3. If not, throw a meaningful error Either way, don't propagate the nulls further than they need to go.