TypeScript: The DX of editing TypeScript

I think the key aspect of using TypeScript is in the developer’s experience (DX) that it gives us.

The end result of TypeScript will be JavaScript without types.

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.

While working on your app in the editor, the editor will be able to automatically understand if the program has an error, much more than what it can do with JavaScript.

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.

In plain JavaScript we have JSDoc, and many libraries prefer using this.

What matters is that our life is easier either way.

You can decide to use JavaScript, but the benefits using other libraries are the same.

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.

JavaScript is great because it’s dynamic and gives you a lot of freedom. But freedom can be a double-edged sword, because it’s a bit too permissive.

But we’re lucky enough to be able to choose between those 2 “versions” of JavaScript. You can pick the one you like the most, depending on the situation you’re facing.

Lessons in this unit:

0: Introduction
1: Your first TypeScript program
2: Types
3: Typing functions
4: The editor helps you with type errors
5: Running TypeScript code
6: Valid types
7: Type aliases and interfaces
8: Union types
9: Typing arrays with generics
10: ▶︎ The DX of editing TypeScript
11: There's more...
12: tsconfig.json COMING SOON
13: Installing types COMING SOON
Are you intimidated by Git? Can’t figure out merge vs rebase? Are you afraid of screwing up something any time you have to do something in Git? Do you rely on ChatGPT or random people’s answer on StackOverflow to fix your problems? Your coworkers are tired of explaining Git to you all the time? Git is something we all need to use, but few of us really master it. I created this course to improve your Git (and GitHub) knowledge at a radical level. Launching May 21, 2024. Join the waiting list!