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.

TypeScript is a superset of JavaScript that adds optional static types which can be checked by the TypeScript compiler to catch common errors in your programs. TypeScript can use this information to help you avoid about mistakes like typos, missing arguments, or forgetting to check for null and undefined.

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.

The new release has also added control over module detection.This overcomes the problem incurred by the introduction of modules to JavaScript, specifically the ambiguity between existing "script" code and the new module code. JavaScript code in a module runs slightly differently, and has different scoping rules, so tools have to make decisions as to how each file runs. TypeScript now deals with this correctly.

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.

More Information

TypeScript On NuGet

TypeScript On GitHub

Related Articles

TypeScript 4.5 Adds Awaited

TypeScript 4.4 Improves Control Flow Analysis

TypeScript 4.3 Adds Separate Property Write Types

TypeScript 4.2 Release Candidate Available

New TypeScript Website Launched

TypeScript 4.1 Adds Temporal Literal Types

 

To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on Twitter, Facebook or Linkedin.

Banner


Christie's Make Over $16 Million From Paul Allen's Collections
29/09/2024

The recent Christie's auction sale of historic computers collected for his Living Computer Museum by Paul Allen saw a Cray 1, sell for over $1million, four times higher than its estimate. The computer [ ... ]



Spring One 2024 Sessions Now Available Online
04/10/2024

The sessions from this year's SpringOne conference covering everything and anything concerned with the Spring framework are accessible online for free.


More News

kotlin book

 

Comments




or email your comment to: comments@i-programmer.info