|TypeScript 4.7 Adds Node.js ECMAScript Module Support|
|Written by Kay Ewbank|
|Monday, 06 June 2022|
TypeScript 4.7 has been released with improvements including ECMAScript module support in Node.js, instantiation expressions, and control-flow analysis for computed properties.
The headline improvement in the new release is the ECMAScript module support in Node.js. The developers of Node.js have been working for several years to add support for ECMAScript modules (ESM). The work has taken so long because it's been difficult to achieve, because the Node.js ecosystem is built on a different module system called CommonJS (CJS). Support for ESM in Node.js was largely implemented in Node.js 12, and TypeScript now adds support for ESM in Node.js.
The addition of support for control-flow analysis for computed properties means that TypeScript 4.7 now analyzes the type of computed properties and narrows them correctly. ontrol-Flow Analysis for Bracketed Element Access
TypeScript 4.7 also now narrows the types of element accesses when the indexed keys are literal types and unique symbols.
Other improvements include snippet completions for object literal methods; a change to Organize Imports so it recognizes groups and handles them correctly; and the ability to perform typeof queries on private fields.
TypeScript 4.7 is available now.
or email your comment to: firstname.lastname@example.org