TypeScript’s Rapid Rise to Prominence, Explained
by Tom Helvick
Since its release in 2012, TypeScript has seen an impressive rise. At first, TypeScript was part of a crowded field of compile-to-JavaScript solutions. Languages like CoffeeScript and Dart were popular. However, TypeScript’s tooling and commitment to JavaScript fundamentals won out.
In this post, we’ll explore why TypeScript succeeded. In addition, we’ll see that TypeScript seems ready for greater growth. As business logic and key features of applications increasingly rely on JavaScript, TypeScript is poised to snatch up greater market share.
What is TypeScript?
In brief, TypeScript is a superset of JavaScript that makes building complex web application easier. Its main feature is the addition of optional type checking into JavaScript code. Whereas JavaScript is dynamically typed, TypeScript can be (but doesn’t have to be) statically typed. Overall, static typing reduces bugs from type switching. It also allows developers to catch type errors at compile time.
Moreover, TypeScript introduces new features to JavaScript. For example, TypeScript supports classes, methods, and interfaces for building more modular object-oriented web programs.
Finally, TypeScript standardizes these types and features across runtimes. As a matter of fact, by default, TypeScript compiles to the older ES3 JavaScript. It supports a host of new features built on an older version of JavaScript that all browsers can run.
TypeScript is a language from Microsoft.
Commitment to ECMA Standard
One reason TypeScript has been so popular is its support of JavaScript’s ECMA standards. Whereas other compile-to-JavaScript solutions, like Dart, disparaged JavaScript, TypeScript supports it. Indeed, Dart sought to replace JavaScript with a new client-side language entirely. TypeScript, on the other hand, leverages the web infrastructure built around JavaScript. Modern browsers support TypeScript natively because TypeScript is JavaScript.
In fact, you can write raw JavaScript in a TypeScript file and it will compile. As a result, existing projects can gradually add TypeScript over time. They don’t have to start from scratch. TypeScript makes JavaScript easier to write, debug, and maintain.
When new versions of Javascript ship each year, TypeScript supports the new features while also providing backward compatibility.
Static types are opt-in
TypeScript is known for its static typing. It’s in the name, after all. However, many devs who haven’t worked with TypeScript don’t know that the typing is optional. Therefore, you can add typing into your projects over time.
It’s simple to get started with TypeScript types. Just declare them with a colon:
var myGreeting: string;
myGreeting = “Hello World!”;
Overall, TypeScript’s types are easy to learn and fairly intuitive. Of course, many developers hate the overhead of static typing. Nevertheless, there’s a strong argument that typing prevents bugs. Implicit typing and type conversions are a common source of bugs.
When the Slack engineering team ported over their application to TypeScript, they found tons of small bugs like this. From the Slack blog:
“The more lines of code a human writes, the more inevitable it becomes to misspell a property, assume the parent of a nested object to always exist, or to use a non-standard error object.”
Tooling
Another major benefit of TypeScript is the productivity tools for TypeScript developers. Since TypeScript is a Microsoft language, VS Code has lots of features built in for it. Autocomplete and linting are available on modern editors. This includes predictive and context-based code generation that make writing TypeScript much faster.
Additionally, in-line documentation can remind you of syntax or usage. Furthermore, type errors and compile bugs raise flags on the fly in the editor.
These aren’t just trivial, nice-to-have tools. Over time, the productivity gains from these features really add up.
Angular & Vue run on TypeScript
Angular and Vue, two of the most popular frontend frameworks, use TypeScript. In addition, Reactoptionally supports TypeScript. This makes sense because TypeScript is a superset of JavaScript. It has everything JavaScript has and more!
Angular’s decision to use TypeScript was a key catalyst for TypeScript’s rise. With the backing of both Microsoft and Google, it’s clear why the language is growing so rapidly.
According to RedMonk’s most recent ranking of programming languages, TypeScript sits at #12 and rising rapidly.
JavaScript at Scale
TypeScript’s selling point is that it makes it easier to build scalable JavaScript applications. As shown above, TypeScript possesses all the features of JavaScript, plus more. At this point, it’s clear that adoption is strong and TypeScript is here to stay. It allows companies to build maintainable JavaScript applications at scale. With the web eating the world and frontend eating the web, it makes sense that JavaScript (and therefore TypeScript as well) will continue to grow in importance.
About Intertech
Founded in 1991, Intertech delivers software development consulting and IT training to Fortune 500, Government and Leading Technology institutions. Learn more about us. Whether you are a developer interested in working for a company that invests in its employees or a company looking to partner with a team of technology leaders who provide solutions, mentor staff and add true business value, we’d like to meet you.
…
Originally published at Intertech blog.