New Features in TypeScript 4.9 Beta
The TypeScript 4.9 beta, released on September 23 2022 and installable via npm or the VS Code Nightly extension, introduces a new satisfies operator, upcoming --noImplicitSuffix option, per‑file @ts‑* directives, refined in operator narrowing, NaN equality warnings, an updated Promise.resolve signature, and preserves import statements in JavaScript files, while postponing full decorator support to version 5.0.
TypeScript 4.9 beta was released on 2022‑09‑23. The beta can be installed with npm install typescript@beta or by using the JavaScript and TypeScript Nightly extension in VS Code.
The release notes highlight several major additions:
ECMAScript decorator support is postponed to the upcoming 5.0 release; the experimental --experimentalDecorators and --emitDecoratorMetadata flags remain for the old decorators.
The new satisfies operator enables safe up‑casting while preserving the inferred property types. Example: const palette = { red: [255,0,0], green: "#00ff00", blue: [0,0,255] } satisfies Record<Colors, string | RGB>;
Import paths with a .ts suffix can be enforced via the upcoming --noImplicitSuffix compiler option, aligning TypeScript with Deno’s import style.
Single‑file tsconfig directives such as @ts-check , @ts-nocheck , and other @ts‑* comments can now be placed at the top of a file to control checking on a per‑file basis.
The in operator now narrows unlisted properties to object & Record<"userId", unknown> , improving type‑guard precision.
NaN equality checks now warn against using value === NaN and suggest Number.isNaN(value) instead.
The type signature of Promise.resolve was updated to return Promise<Awaited<T>> , providing more accurate resolved types.
JavaScript files now retain all import statements during compilation, preventing accidental removal of type‑only imports.
These enhancements aim to make type safety tighter, improve developer ergonomics, and bring TypeScript closer to the evolving ECMAScript specifications.
DaTaobao Tech
Official account of DaTaobao Technology
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.