| > If your types are wrong your program is wrong That's not necessarily true though is it? If the "1" in the "1 hour ago" message in the header of your reply wasn't the expected type of the writer of the output function but ultimately still shows up as "1 hour ago" to the user, there's no user-facing defect. I can promise you that this happens all the time in javascript. You're in a thread about Javascript. > have you ever tested what happens when you pass "null" into a function Not that I recall. Javascript will throw an appropriate error when it detects that your duck isn't quacking correctly. No one writes validation logic everywhere on internal units, so there's no functionality to verify with a test. With that said, null is decidedly not "just a type". It's also a value. I generally avoid using null everywhere as much as possible too, because it's a pretty terrible concept. > Some type systems allow you to even specify valid subranges of types, and combined with algebraic data types, it's effectively impossible to misuse. Sure but you're in a thread about javascript and typescript. And let's be honest: the vast majority of type systems do not support that. |