TypeScript 4.7 officially became available on May 24, marking a significant update for the popular strongly-typed superset of JavaScript. With this release, Microsoft introduces important enhancements, including official support for ECMAScript modules (ESM) in Node.js 16. This marks an exciting development for developers as ESM offers improved modularity and code reuse. The release also includes numerous other improvements aimed at making TypeScript easier and more efficient for developers to use in a variety of JavaScript environments.
One of the major highlights of TypeScript 4.7 is the integration of ESM support for Node.js 16, which came in as a last-minute addition. Originally, the beta version of TypeScript 4.7, released in April, featured ESM support for Node.js 12. However, since Node.js 12 reached its end of life, the stable version of TypeScript 4.7 was built with Node.js 16 as the target. This provides developers with access to more advanced ECMAScript module features like pattern trailers and supports top-level await by default, further streamlining asynchronous code execution.
The inclusion of ESM support is part of a broader effort to move away from the traditional CommonJS module system that Node.js originally used. This shift allows for better code packaging and reusability, essential for modern JavaScript development. TypeScript 4.7 also continues to refine this functionality, offering two new module settings: node16
and nodenext
. These settings ensure that developers can take full advantage of the latest features in JavaScript module management, making it easier to work with libraries and frameworks that use ESM.
As part of the ongoing improvements to ESM support, TypeScript 4.7 encourages developer feedback through GitHub, where the community can share their experiences and contribute to refining the module system. This collaborative approach ensures that TypeScript remains at the forefront of JavaScript development, helping developers manage larger projects with greater flexibility and fewer headaches.