X
Business

Programming language TypeScript 3.9 cuts compile times by up to 40%, says Microsoft

Microsoft's TypeScript 3.9 JavaScript spin-off brings major compile time improvements for popular JavaScript libraries.
Written by Liam Tung, Contributing Writer

Microsoft's TypeScript team have released version 3.9 of its young programming language, a superset of JavaScript that compiles to JavaScript code to run in the browser or outside the browser on Node.js. 

Microsoft released TypeScript in 2012 for large JavaScript projects, and it's quickly become one of the most popular programming languages for developers. TypeScript was created by the creator of C#, Anders Hejlsberg, who continues to maintain the language today. 

One of the main improvements in TypeScript 3.9 is faster compile times, in particular for the popular UI libraries styled-components and material-ui, a component for Facebook-developed JavaScript web framework React for Google Material Design web apps. 

SEE: How to build a successful developer career (free PDF)

Through several pull requests, the TypeScript team have optimized "certain pathological cases involving large unions, intersections, conditional types, and mapped types" to achieve huge compile time improvements. 

"Our team has been focusing on performance after observing extremely poor editing/compilation speed with packages like material-ui and styled-components," the team writes

"Each of these pull requests gains about a 5% to 10% reduction in compile times on certain codebases. In total, we believe we've achieved around a 40% reduction in material-ui's compile time."

A Microsoft engineer who works on the Outlook Web App says upgrading to TypeScript 3.9 has cut his compile times from 26 seconds to 10 seconds. 

For those using TypeScript with Microsoft's code editor VS Code, a change to how renaming files is handled also speeds things up. 

TypeScript 3.9 introduces a new feature '// @ts-expect-error comments' to improve error reporting clashes between JavaScript and TypeScript. 

Daniel Rosenwasser and the TypeScript Team have published a blogpost explaining further changes in the 3.9 release to improve the TypeScript editor experience, its checks on intersections and optional properties, and improvements to TypeScript's compliance with the ECMAScript specification behind JavaScript. 

SEE: Microsoft's VS Code 1.45 is out: GitHub integration plus JavaScript debugger update

Microsoft expects to release the TypeScript 4.0 beta in late June and, after a round of release candidates, it plans to roll out TypeScript 4.0 on August 18. 

As Rosenwasser explains, TypeScript adds syntax to JavaScript that can be used by the TypeScript compiler to type-check code and then output clean, readable JavaScript. The advantage of static type-checking is that developers can see errors in code before running it or saving files.   

More on Microsoft's TypeScript and programming languages

Editorial standards