TypeScript, Microsoft’s statically-typed superset of JavaScript, has released TypeScript 5.9, shipping with a mix of developer experience improvements, new features, and performance optimizations.
TypeScript 5.9 introduces several features, including support for deferred imports, an improved default project setup via the scaffolding flag, and a more stable module resolution mode for Node.js v20. It also announces a new expandable hover preview.
One of the headline features in TypeScript 5.9 is support for the proposed import defer syntax, part of a stage-3 ECMAScript proposal. This feature allows developers to defer the loading and execution of a module and its dependencies until the moment the imported property is accessed.
The syntax for deferred imports is similar to a regular import, except there are some rules, such as not being able to use named imports or default imports. An example of the correct syntax is shown below:
import defer * as expensiveLibrary from 'expensive-library'
Developers that are scaffolding new TypeScript configurations and using the tsc –init
command will now be presented with a leaner tsconfig. The change has been implemented based on feedback indicating that it is common for developers to delete a lot of the automatically generated contents of tsconfig.json files. With the new changes developers will now get a more concise file, and be able to make use of editor autocompletion and the tsconfig reference on the TypeScript website to add in the specific config required.
Alongside the existing nodenext module mode, this new version of TypeScript will introduce a node20 module option. The option is intended to mirror the behaviour of Node.js v20 and as a result will not be likely to include future features or behaviors in the same way the ‘nodenext’ mode would. The exception to this would be if the NodeJS team backport new module behavior to Node.js v20.
In tools such as Visual Studio Code, TypeScript 5.9 brings improvements to the developer experience with the introduction of expandable type previews. The goal of this new feature is that for deeply nested types, a new ‘+’ and ‘-’ button will be available so developers can dig deeper into types, reducing the need to jump directly into the definition files. This new feature has prompted some excitement from the community, with users on reddit already highlighting the convenience of the new feature:
Im very excited about import defer, but I think that the Summary Descriptions and the Expandable Hovers are going to be the biggest game changer with newbies. A lot of TypeScript felt esoteric and abstruse to me when I first learned it, so making the underlying information more immediately available is definitely a good move.
There are some behind the scenes performance upgrades also shipped as part of TypeScript 5.9. These include cache instantiations on mappers to reduce unnecessary instantiating of the same intermediate types multiple times, and optimised file existence checks which on larger projects could have a speed increase of around 11%.
The release notes for 5.9 also give a glimpse into future releases. While the team are focussing on their recently announced port of TypeScript compiler to Go, currently planned for TypeScript v7, they have indicated that version 6 will be more of a bridge release to alllow developers to prepare for version 7.
TypeScript is an open-source programming language developed and maintained by Microsoft. It builds on JavaScript by adding optional static typing, making it easier to catch errors early and build large-scale applications with confidence. TypeScript is widely adopted across frontend and backend ecosystems, with first-class support in frameworks like React, Angular, Vue, and Node.js.