3 ms·
If "| undefined" is spreading through your code like a virus in cases where it's not actually optional, then I'd argue that the problem is upstream where the da
by munchbunny 6y ago
If "| undefined" is spreading through your code like a virus in cases where it's not actually optional, then I'd argue that the problem is upstream where the data is ingested, and the code should be enforcing "must be defined" at input validation so that you can carry a clean "Color" type everywhere else.
If it's about optional parameter weirdness and TypeScript's lack of method overloading, I suspect that's inherited from JavaScript's laxness with method signatures. I don't like it either.
- zaccusl 6y agoTypeScript does have method overloading same as other typed languages (except you have to do runtime checks, but that is a JavaScript limitation).
- munchbunny 6y ago> except you have to do runtime checks, but that is a JavaScript limitation IMO not having to do runtime checks is a big part of the value proposition of method overloading the way many languages do it. Whether or not it’s a limitation inherited from JavaScript, it’s still really klunky compared to other mainstream languages. It’s one of the few things that I actually dislike about TypeScript, despite overall loving it.