4 ms·
Validation functions are pretty easy to write, as long as your data is being handled in a predictable way.
by crooked-v 7y ago
Validation functions are pretty easy to write, as long as your data is being handled in a predictable way.
- uk_programmer 7y agoYes. However you can for example do the following in typescript: function someFunction(obj?:DuckType) { //Snip other logic someOtherFunction(obj); } function someOtherFunction(obj:DuckType) { } The type checker catch that. So you still have to do: function someFunction(obj?:DuckType) { obj = obj || { /* set some object properties */ //Snip other logic someOtherFunction(obj); } function someOtherFunction(obj:DuckType) { } I have found plenty of examples where people haven't set a default value because the compiler hasn't flagged anything wrong with the code and you get an uncaught reference error.