| Some Typescript value added: - Living documentation: types are a clear description of how your code and its data are laid out, and this structure is kept always up-to-date with the code, regardless of future changes. If the "documentation" (the typing) is wrong, the compiler will complain. - Better tooling: autocomplete, more robust auto-refactoring - Elimination of an entire class of bugs. This class may include:
1. `Cannot read property 'foo' of undefined`
2. forgeting a case in a switch statement
3. `'foo' is not a function`
4. in general, your code receiving data that isn't laid out in a way you expected (Property typos is one within this class of bugs, but it is not all of it) Yes tests catch these bugs as well. But tests are also manually written. And often not written at all. A compiler makes these (mundane) sanity checks automatic and mandatory. --- Typescript's slogan is "JavaScript that scales" because static typing improves: dev documentation (via types living inside the code) and dev tooling (refactoring and autocomplete), both of which help immensely as a project grows in age (devs become forgetful), team size (new developers get lost), and convolutedness (e.g. tech debt). |
auto-refactoring.. yeah we all trust that. Until you come to the boundaries where all the types don't exist, like from the client to the server, to the database via its message system, etc. All the stuff coming in and out of your code is untyped.
Autocomplete works without typescript, even if it uses "the typescript engine". The types aren't needed.
Eliminates an entire class of bugs that nobody has ever had a problem with.