TypeScript 4.7 was officially released as a production version on May 24, bringing with it significant enhancements that improve both functionality and developer experience. This latest version of Microsoft’s strongly typed JavaScript includes full ECMAScript module (ESM) support for Node.js 16, a much-anticipated feature. Additionally, TypeScript 4.7 introduces a variety of coding enhancements aimed at refining the language’s capabilities and ensuring better compatibility with modern JavaScript features.
A key highlight of TypeScript 4.7 is the addition of ESM support for Node.js 16, which was a last-minute inclusion in the release. Earlier in the beta phase, TypeScript 4.7 offered support for Node.js 12, a version originally targeted for ESM functionality in TypeScript 4.5. However, since Node.js 12 reached end-of-life, the focus shifted to Node.js 16 as the stable target for ECMAScript module support. This shift ensures that TypeScript benefits from the latest features of ESM, such as pattern trailers and top-level await, both of which are important for writing modern, efficient code.
TypeScript’s journey with ECMAScript modules has been a gradual one, starting with nightly-only support in the TypeScript 4.5 timeframe. ESM modules allow developers to package and reuse code more effectively, which is increasingly important as applications scale. Implementing this support in TypeScript has been a challenge due to Node.js’s original reliance on the CommonJS module system. TypeScript 4.7 addresses this by introducing two new module resolution strategies—node16 and nodenext—which are designed to better handle ECMAScript modules in Node.js environments.
As always, feedback from the developer community is crucial in refining these features, and the TypeScript team has encouraged users to provide their insights via GitHub. With TypeScript 4.7, Microsoft continues to push the envelope on improving developer tooling and aligning TypeScript with the evolving JavaScript landscape, ensuring that it remains a powerful tool for modern web development.