I think the key aspect of using TypeScript is in the developer’s experience (DX) that it gives us.
Because the browser cannot understand types (yet?), they are stripped away once the program is compiled to JS.
So what are they for?
They are for the editing experience.
So you can catch possible sources of problems before even running your code.
And, as an additional benefit, when you’re writing code, the editor (VS Code for example, but others too if set up for this) will give you hints about the types, the variables and parameters that you should write.
And you commonly get this “for free” when using libraries that provide types.
TypeScript is not the only way to do this.
What matters is that our life is easier either way.
And if you choose to use TypeScript, you can benefit from having types in your code, something that I think makes sense when your app grows larger, and you are working with a team of people.
When you can’t keep all the code in your head any more.
TypeScript gives you more structure and things to worry about. It forces you to think about types, and sometimes for simple projects you might find it gets in the way.
Lessons this unit:
|1:||Your first TypeScript program|
|4:||The editor helps you with type errors|
|5:||Running TypeScript code|
|7:||Type aliases and interfaces|
|9:||Typing arrays with generics|
|10:||▶︎ The DX of editing TypeScript|
|12:||tsconfig.json COMING SOON|
|13:||Installing types COMING SOON|