TypeScript 3.9 slashes compile times for packages

Latest TypeScript production release addresses extremely poor editing and compilation speeds associated with packages

TypeScript 3.9 slashes compile times for packages

TypeScript 3.9, the latest version of the popular typed superset of JavaScript from Microsoft, is now available as a production release. The upgrade graduated from a release candidate stage and cross the finish line on May 12, 2020. 

TypeScript 3.9 emphasizes performance, polish, and stability. Microsoft has focused on fixes to address extremely poor editing and compilation speeds associated with some packages. The release can be installed through NuGet or NPM:

npm install typescript

The TypeScript team had observed performance issues with packages such as material-ui and styled-components. A series of six pull requests, covering operations such as using objects instead of closures for type mappers and optimizing of deferred type references, have resulted in significant reductions of compile times — roughly 25 percent in the case of material-ui, for example.

Also to boost speed, some changes have been made to file renaming functionality in editor scenarios. TypeScript 3.9 also includes improvements in a number of other areas. The highlights:

  • Improvements to the inference process, addressing a situation in which some regressions had occurred in previous updates to the declarations of functions like Promise.all and Promise.race.
  • New // @ts-expect-error comments. When a line is prefixed with this comment, TypeScript will suppress the error from being reported. If there is no error, TypeScript will report that the comment was unnecessary.
  • Improvements to preserve newlines.
  • Quick fixes for missing return expressions.
  • Support for “Solution Style” tsonfig.json files.
  • Uncalled function checks, introduced in TypeScript 3.7 to report an error when a developer forgot to call a function, are now supported in ternary conditionals, essentially, the cond ? trueExpr : falseExp syntax.
  • For CommonJS auto-imports in JavaScript, TypeScript now automatically detects the types of imports being used to keep a file’s style clean and consistent.
  • Stricter checks on intersections and properties. This is a breaking change.
  • Getters and setters are no longer enumerable. Another breaking change, this pertains to a situation with older versions of TypeScript in which get and set accessors in classes were emitted in a way that made them enumerable, which was not in compliance with the ECMAScript specification.

Introduced in beta on March 27, TypeScript 3.9 follows TypeScript 3.8, which became available in February. Not included in TypeScript 3.9 is an awaited type operator to model the way Promise unwrapping works in JavaScript. It had been anticipated for the release, but has been pulled from the main branch until more work can be done on it.

Copyright © 2020 IDG Communications, Inc.

How to choose a low-code development platform