ESM support for Node.js 16 was a late addition to the release. The TypeScript 4.7 beta introduced April 8 involved ESM guidance for Node.js 12, which had been planned for TypeScript 4.5 late last yr but was delayed.
Having said that, since Node.js 12 is no for a longer time supported, TypeScript’s builders started off the stable goal at Node.js 16, which gives newer ECMAScript module features these types of as pattern trailers when also defaulting TypeScript to a increased concentrate on that supports leading-level
Nightly-only support for ECMAScript modules in Node.js was rolled out in the TypeScript 4.5 timeframe. These modules enable reuse of code through packaging. Implementing this guidance has been hard for the reason that Node.js was developed on a distinctive module process, CommonJS. TypeScript 4.7 provides this performance with two
nodenext. Feed-back on this capability is sought and can be available on GitHub.
TypeScript 4.7 can be downloaded through NuGet or NPM:
npm install -D typescript
Other capabilities in TypeScript 4.7 include the following:
- Handle movement investigation for bracketed ingredient entry now narrows the varieties of element accesses when the indexed keys are literal forms and exclusive symbols
- To manage module detection, TypeScript 4.7 introduces the alternative
moduleSuffixespossibility is supported to personalize lookup of module specifiers.
- TypeScript now can carry out much more granular inferences from features with objects and arrays. This allows types of these features to constantly stream in a left-to-ideal fashion, just like for simple arguments.
- Features and constructors can be fed kind arguments right.
- Builders can explicitly specify variance on form parameters.
- Manage Imports is done in a group-mindful manner.
- Snippet completions are furnished for item literal strategies.
readonlytuple now will address its
readonly. This is a breaking modify.
- A preview editor command is featured for Go to Supply Definition.
- In an additional breaking adjust, when composing a
…spreadin JSX, TypeScript now enforces stricter checks that the offered variety is really an object. As a end result, values with the styles
never ever, and, more almost never,
undefined, no lengthier can be unfold into JSX aspects.
Pursuing the beta, TypeScript’s builders located that a
typeof capability on
#private fields, which had been prepared for the launch, had challenges with API compatibility. The crew also began doubting no matter whether
typeof this.#somePrivate composes effectively on declaration emit. As a result, this ability has been left out of TypeScript 4.7.
A launch applicant for TypeScript 4.7 was revealed on May perhaps 11. The earlier edition, TypeScript 4.6, which brought capabilities this sort of as ECMAScript 2022 aid and recursion checks, was revealed February 28.
Copyright © 2022 IDG Communications, Inc.