← Impulso Blog

Who's afraid of TypeScript?

Stop missing out on opportunities because you're afraid of TypeScript! Learn what it's all about and get plenty of tips to help you use it with confidence.

TypeScript

Editorial translation by Impulso.

Do you use TypeScript? Or are you one of those developers who are afraid to use it? If you're in the second camp, listen up: you could be missing out on some incredible opportunities in your day-to-day work.

Here are some of the key insights that William Grasel (web developer, Google Developers Expert, and AngularSP coordinator) shared with us in an incredible talk on TypeScript here at Impulso. Ready to dive in with us? 🚀

Why are people afraid of TypeScript?

A person reads code on two external monitors while working on a laptop.

The fact is, many people are very reluctant to use TypeScript alongside JavaScript, and that reluctance turns into a real fear of using it. Many experts argue:

[ads-quote-center cite='']“Oh, but they already tried that in ES4, and it didn't work.”[/ads-quote-center]

But really, who says that's what caused ECMAScript 4's problems? It had a number of other issues that contributed to its failure, including various bugs and breaks in backward compatibility – a critical issue for JavaScript projects.

The fact is, we've seen new approaches to typing since then. For example:

  • Google Closure Compiler + JSDocs (types in the documentation itself);
  • ECMAScript Typed Objects Proposal (a proposal to bring typing back, though it's still in its early stages and moving slowly toward that goal);
  • Web Assembly + SIMD.js (has low-level types);
  • Microsoft TypeScript;
  • Facebook Flow.

What is TypeScript?

What is TypeScript

Microsoft introduced TypeScript as open source. This typed superset has some important specifications, such as:

  • All valid JavaScript must be valid TypeScript, so nothing can conflict directly with JavaScript. In other words, you don't have to learn a new language;
  • It promises to stay aligned with the future of ECMAScript;
  • All additional features are strictly optional, so you don't have to use any of them;
  • It works as a transpiler (it takes modern JavaScript, with all its “switchers”, and transpiles it to an older version) and a bundler (it combines multiple files into a few so they can be downloaded more efficiently to the user's machine), like Babel;
  • It changes your code as little as possible when transpiling;
  • It focuses on tooling and statistical code analysis;
  • It makes it easier to refactor and grow large codebases.

Who's using TypeScript?

Who's using TypeScript

While many developers are reluctant to use TypeScript, others are investing heavily in its adoption. These include:

  • Google (TypeScript is one of Google’s 5 official languages);
  • Companies like Airbnb, Reddit, Paypal, and Lyft, which have migrated or are in the process of migrating from JavaScript to TypeScript;
  • There are more than 200,000 open-source projects on GitHub that use TypeScript;
  • Web frameworks such as Angular, Ember, Vue, Aurelia, and Cycle.js;
  • Mobile frameworks such as Ionic and NativeScript;
  • Desktop apps such as VS Code and Slack.

It's also one of the languages developers love most 🧡, according to the Stack Overflow Survey.

So how do you get over your fear of TypeScript?

A person raises both arms in front of two computers displaying code.

With that in mind, William Grasel suggests 5 steps to ease you into TypeScript without the growing pains. Are you ready?

  1. Purist: You can use plain JavaScript/ECMAScript without adding any types or using any TypeScript features. You'll use it much like Babel to transpile and bundle your application. You don't need the .ts extension either. You can use .js, .jsx, .vue, and others. You still get IntelliSense and type inference
  2. Beginner: Start adding types to some function parameters and return values. Let TypeScript help by giving you extra information;
  3. Intermediate: Start creating and implementing data interfaces. This gives you even more help from IntelliSense and protects large data structures. Remember that these are interfaces for data, not for objects, so they aren't like interfaces in C# or Java;
  4. Advanced: Start exploring more advanced features. Learn how generic types work and make the most of them. Know what an Array, Promise, or Observer contains before the code even runs;
  5. GodMod: Start enabling all available safety flags and keep following safe coding practices.

These steps will help you get started with TypeScript and learn to use it with confidence. Put William Grasel's tips to good use and don't let fear cost you any more opportunities! 

Enjoyed this and want to learn more? 🎬 Check out what happened in this great talk! ⬇

https://www.youtube.com/embed/J9OoXt1dvm8

Related articles