Maybe this is a very lame question but I'm not a JavaScript professional. Please excuse my very basic question. We all do know that JavaScript (node.js) is a dynamically typed language. Moreover, one can simply write:
someObject.attr = 123;
But because of no compile-time checking we can also misspell the attribute name and write:
someObject.misspelledAttr = 123;
and produce a bug.
My question is: What is the most principal and currently used solution for that problem? Writing tests? Some tools? I have no idea if there even could be any "strong" solution.
As for tools, there are languages like TypeScript that add compile-time checking. So you get a language that is very close to Javascript with some extra annotations, and it compiles to regular Javascript.
Also, if your text editor does autocompletion based on words that already exist in the project, that goes a long way, too, as far as typos go.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With