Depends on whether you set the TS compiler to strict mode or not. I personally prefer having to add null or undefined to the type, so you can avoid checking for null-ish values before every function call, as long as you aren't writing library code at least.
-1
u/ef02 Jun 20 '21
The
| nullis unnecessary in TypeScript, but other than that, it seems fine.