Improving code quality with type safety, linters, and code formatters
As already mentioned in Chapter 2, Understanding the Essentials of JavaScript and TypeScript, it is necessary to use typed JavaScript alongside some tools to ensure a certain level of quality in bigger projects.
In the following section, you will learn how to do this. Let’s start with type safety using TypeScript or Flow.
Ensuring type safety with TypeScript or Flow
Type safety is standard in most programming languages such as Java or C#, and this is for good reason. In contrast, JavaScript is dynamically typed. This is because of the history of JavaScript. Remember, JavaScript was created as a scripting language to write small chunks of code very quickly. For this scenario, dynamic typing is fine, but when a project grows, static typing with all its advantages is a must-have.
Using typed JavaScript creates some overhead for creating your types at the beginning, but it gives you a lot of advantages...