The latest version of Microsoft’s strongly typed JavaScript introduces support for ECMAScript modules in Node.js, adds coding enhancements. Credit: Thinkstock TypeScript 4.7 became generally available as a production release on May 24. The latest version of Microsoft’s strongly typed JavaScript, TypeScript 4.7 arrives with ECMAScript module (ESM) support for Node.js 16 as well as a multitude of coding enhancements. ESM support for Node.js 16 was a late addition to the release. The TypeScript 4.7 beta introduced April 8 included ESM support for Node.js 12, which had been planned for TypeScript 4.5 late last year but was delayed. However, because Node.js 12 is no longer supported, TypeScript’s builders started the stable target at Node.js 16. This not only provides newer ECMAScript module functionality such as pattern trailers, but also defaults TypeScript to a higher target that supports top-level await. Nightly-only support for ECMAScript modules in Node.js was rolled out in the TypeScript 4.5 timeframe. These modules enable reuse of code via packaging. Implementing this support has been difficult because Node.js was built on a different module system, CommonJS. TypeScript 4.7 adds this functionality with two module settings, node16 and nodenext. Feedback on this capability is sought and can be offered on GitHub. TypeScript 4.7 can be downloaded via NuGet or NPM: npm install -D typescript Other capabilities in TypeScript 4.7 include the following: Control flow analysis for bracketed element access now narrows the types of element accesses when the indexed keys are literal types and unique symbols To control module detection, TypeScript 4.7 introduces the option moduleDetection. A moduleSuffixes option is supported to customize lookup of module specifiers. TypeScript now can perform more granular inferences from functions with objects and arrays. This allows types of these functions to consistently flow in a left-to-right manner, just like for plain arguments. Functions and constructors can be fed type arguments directly. Developers can explicitly specify variance on type parameters. Organize Imports is performed in a group-aware manner. Snippet completions are provided for object literal methods. A readonly tuple now will treat its length property as readonly. This is a breaking change. A preview editor command is featured for Go to Source Definition. In another breaking change, when writing a …spread in JSX, TypeScript now enforces stricter checks that the given type is actually an object. As a result, values with the types unknown and never, and, more rarely, null and undefined, no longer can be spread into JSX elements. Following the beta, TypeScript’s builders found that a typeof capability on #private fields, which had been planned for the release, had issues with API compatibility. The team also began doubting whether typeof this.#somePrivate composes well on declaration emit. As a result, this capability has been left out of TypeScript 4.7. A release candidate for TypeScript 4.7 was published on May 11. The previous version, TypeScript 4.6, which brought capabilities such as ECMAScript 2022 support and recursion checks, was published February 28. Related content feature 14 great preprocessors for developers who love to code Sometimes it seems like the rules of programming are designed to make coding a chore. Here are 14 ways preprocessors can help make software development fun again. By Peter Wayner Nov 18, 2024 10 mins Development Tools Software Development feature Designing the APIs that accidentally power businesses Well-designed APIs, even those often-neglected internal APIs, make developers more productive and businesses more agile. By Jean Yang Nov 18, 2024 6 mins APIs Software Development news Spin 3.0 supports polyglot development using Wasm components Fermyon’s open source framework for building server-side WebAssembly apps allows developers to compose apps from components created with different languages. By Paul Krill Nov 18, 2024 2 mins Microservices Serverless Computing Development Libraries and Frameworks news Go language evolving for future hardware, AI workloads The Go team is working to adapt Go to large multicore systems, the latest hardware instructions, and the needs of developers of large-scale AI systems. By Paul Krill Nov 15, 2024 3 mins Google Go Generative AI Programming Languages Resources Videos