3 ms·
Types are documentation, very useful in large dynamically- typed code bases.
by sebazzz 8y ago
Types are documentation, very useful in large dynamically- typed code bases.
- z3t4 8y agoType annotations does not replace proper documentation. And with properly named parameters the annotations are not needed. It's also a convention among JavaScript programmers that each function should not only check the parameters, but also convert them, so you can leave out optional arguments, pass a notated object {foo: "bar"}, or pass a string and have the function convert it to an array so you can write foo(bar) instead of foo([bar]) when calling the function. Or convert an object if it's not of the correct instance. This is more fun then annotating types and having a compiler shout out weird errors at you.