Dmitry Nikolaev - stock.adobe.co

Microsoft makes TypeScript 4 generally available

Microsoft has made TypeScript 4 generally available for developers building large systems in JavaScript. TypeScript, a superset of JavaScript, is designed for the enterprise.

Microsoft has made its version 4.0 of its TypeScript programming language generally available with new productivity, scalability and ease-of-use features for developers.

TypeScript is a superset of JavaScript, which means that existing JavaScript programs are also TypeScript programs. TypeScript was designed for building large enterprise systems. Essentially, TypeScript builds on top of JavaScript by adding syntax for static types. A static typed programming language is one where variables do not need to be defined before they are used.

Key new features in TypeScript 4.0 revolve around a few themes: improving the user experience of using TypeScript, enhancing performance and scalability, and expanding the entry-level experience for developers new to JavaScript and TypeScript.

TypeScript popularity

TypeScript is a core part of many developers' JavaScript stack today, said Daniel Rosenwasser, Typescript program manager at Microsoft, in a blog post. TypeScript had more than 50 million monthly downloads on NPM in July. NPM is the package manager for the Node JavaScript platform. TypeScript also ranked as the second most loved programming language (next to Rust) on the Stack Overflow 2020 developer survey. In the latest State of JS Survey, 89% of developers who used TypeScript said they would work with it again.

There are clear reasons for the language's explosive growth in popularity.

"TypeScript's rapid ascent has been fueled by two things: first, its interoperability with JavaScript, and second, its optional type safety," said Stephen O'Grady, an analyst at RedMonk in Portland, Maine. "JavaScript is everywhere, and if developers can leverage it but do so more safely that's an easy sell."

Microsoft created TypeScript to extend JavaScript by adding types to the language and also bringing type safety to the programming language, which eliminates type errors. As TypeScript is a statically typed superset of JavaScript, it performs additional checks for type errors. A type error occurs when an operation could not be performed, typically when a value is not of the expected type.

"Microsoft has managed to get Typescript into the most popular programming languages by offering value-added capabilities over basic JavaScript which it compiles to," said Holger Mueller, an analyst at Constellation Research. "The 4.0 release is characterized more by Typescript growing up instead of adding substantial new features."

New in TypeScript 4.0

Typescript 4.0 brings improvements to app startup times by speeding up the project loading process. The new release accelerates the program construction step in the TypeScript compiler.

Program construction is "the process of starting with an initial set of files, parsing them, resolving their dependencies, parsing those dependencies, resolving those dependencies' dependencies, and so on," Rosenwasser said in his blog. This can take time, and the bigger the project, the longer the delays a developer might experience before they can get to basic editor operations like code completions, he said.

However, TypeScript 4.0 introduces a new partial experience where the editor can run a partial server that only looks at the files the editor has open. This is "good enough for some basic code completion, quick info, signature help, and go-to-definition when you first open up your editor," Rosenwasser said.

In addition, deprecated support for code editors provides a clear way for library consumers to know which functions should be used and which should be avoided.

"What we're most excited about are the new editor features which greatly increase productivity for developers," said Max Lynch, co-founder and CEO of Ionic, a company based in Madison, Wis., that produces the Ionic cross-platform hybrid development framework. Partial Semantic Mode will enable large TypeScript projects to be editable immediately and improving Auto Import will save developers a lot of time from trying to hunt down package names and import formats, he said.

Other highlights of TypeScript 4.0 include Variadic Tuple Types, Labeled Tuple Elements, Class Property Inference from Constructors, Short-Circuiting Assignment Operators, Custom JSX Factories, speed improvements in build mode, editor improvements including partial semantic mode at startup and a new TypeScript 4.0 website.

"TypeScript 4.0 brings a ton of language ergonomics and typing improvements to developers," Lynch said. "Library authors will welcome the improvements to Variadic Tuple Types, which solves the 'death by a thousand overloads' problem."

And although features like 'variadic tuple types' and 'mapped types' sound like something out of a language theory textbook, these advanced features help to tame complexity at scale in the real world.
Joe DuffyCEO, Pulumi

A tuple is a list of things that are ordered and unchangeable. In TypeScript, a tuple can contain two values of different data types. "A variadic tuple type is a tuple type that has the same properties -- defined length and the type of each element is known -- but where the exact shape is yet to be defined," said Stefan Baumgartner, a Microsoft MVP in Linz, Austria, in a blog post.

TypeScript 4 caps off two years of constant language innovation, including the latest features in the recently released Node.js 14 as well as ECMAScript. The new version includes ECMAScript features like private fields, top-level await in modules, and new export syntaxes.

These releases also provided performance and scalability optimizations. ECMAScript is a JavaScript standard to ensure the interoperability of web pages across different web browsers. The "await" keyword causes the JavaScript runtime to pause a developer's code to allow other code to execute in the meantime.

"Given the amount of async [asynchronous] code in the world, [this] is a huge usability improvement and one of the features we're most excited about," said Joe Duffy, CEO of Pulumi, a Seattle-based provider of DevOps software. "And although features like 'variadic tuple types' and 'mapped types' sound like something out of a language theory textbook, these advanced features help to tame complexity at scale in the real world."

Broad developer base

About a third of developers that use JavaScript also say they use TypeScript, according to Forrester Research.

Jeffrey HammondJeffrey Hammond

"While not as frequently used as Python or Java, TypeScript is getting into margin of error ranges when compared to C# adoption," said Jeffrey Hammond, an analyst at Forrester. "It looks like there's still room for growth at the largest enterprises, especially compared to Java and Python usage."

Moreover, the Stack Overflow data also indicates higher-than-average usage of TypeScript by designers, back-end infrastructure developers and enterprise developers.

"I think that's due to the strong uptake of Typescript by the Angular community," Hammond said. "We also see strong adoption of Angular in enterprise development shops for front end development." Angular is a popular JavaScript framework.

As TypeScript continues to mature, there are significant opportunities for it to continue draw users and make developers lives' easier.

"The ability to infer what a developer is trying to do and just 'make it so' reduces cognitive load and frees a dev up to focus on solving business problems instead of checking to make sure everything is wired up correctly in the plumbing," Hammond said.

Ultimately, the new release gets to some of the more technical issues developers are looking for, particularly those that increase productivity.

For instance, "Partial Semantic Mode will enable large TypeScript projects to be editable immediately and improving Auto Import will save developers a lot of time from trying to hunt down package names and import formats," Lynch said. "Also, refactor support to convert common JavaScript chaining patterns into the new optional chaining and nullish coalescing operator will make code much more readable and less error-prone."

Dig Deeper on Development tools for continuous software delivery

App Architecture
Software Quality
Cloud Computing
Security
SearchAWS
Close