3 ms·
But how often do you forget what properties are required for the config object that is the third argument to your function?
by dkempner 6y ago
But how often do you forget what properties are required for the config object that is the third argument to your function?
- joelbluminator 6y agoI'm not saying it never happens, I just really need to think hard on when it last happened. You're talking about a method that requires a certain param but doesn't raise an exception if you leave it out and then behaves in a buggy way. Again, not something happening a lot.
- com2kid 6y agoEverytime I construct that object I'd have to look up what the fields are, either docs (lol yeah right) or by looking at previous calls. Bonus if my previous usage was incorrect and I didn't notice and I end up copying that same mistake again and again! TypeScript saves me probably 15+ minutes a day of just switching back and forth looking up what parameters are needed. It is a one time tax to make everything I do more pleasant.
- joelbluminator 6y agobtw can't you potentially write methods that receive arbitrary number of arguments in java as well? https://docs.oracle.com/javase/1.5.0/docs/guide/language/varargs.html https://docs.oracle.com/javase/1.5.0/docs/guide/language/var...
- monkpit 6y agoYou’re referring to a variadic function, which can be written in most modern languages. The commenter you are replying to is talking about a function of fixed-arity, with a config object with required props. Which props are required? A Typed language will tell you immediately “for free”.