I get why we prefer final in languages with a need for thread safety, but I have never understood why people prefer const in typescript. I have seen people bend over backwards to avoid a `let` even if it results in higher complexity code. It just doesn’t seem to solve a problem I’ve ever actually encountered in typescript code.
Assuming assert existed, it would almost certainly be judging its value for being falsy, while the ?? operator judges its LHS for being nullish, which is a narrower category. For strings, this affects whether the empty string is acceptable or not.
t-writescode|3 months ago
Null chaining is also a common pattern across most languages and is generally seen as readable
MobiusHorizons|3 months ago
kbolino|3 months ago
xscott|3 months ago
It's a function you could write for yourself and give it whatever semantics you feel is best. No changes to the language required for this one.
fainpul|3 months ago
ameliaquining|3 months ago
xscott|3 months ago
jackblemming|3 months ago
zdragnar|3 months ago