Microsoft releases TypeScript 4.6 with a score of new features
The latest iteration of the programming language brings never-before-seen features and lots of improvements to make developers' lives easier
Microsoft has released the latest version of TypeScript, version 4.6, which brings with it an array of features including some that weren’t included in the beta or release candidate (RC) versions.
Among these is the ability for developers to narrow types based on discriminate properties, something that would throw an error in previous versions of TypeScript.
Microsoft said it comes down to each developer’s preference and how they like to destructure objects into properties.
“When destructuring individual properties into a const declaration, or when destructuring a parameter into variables that are never assigned to, TypeScript will check for if the destructured type is a discriminated union,” said Daniel Rosenwasser, senior program manager of TypeScript at Microsoft. “If it is, TypeScript can now narrow the types of variables depending on checks of other variables.”
Another of the never-before-seen features in TypeScript 4.6 is the support for es2022 in TypeScript’s --target option. It means features like class fields now have a stable output target where they can be preserved.
It also means more recently added TypeScript functionality like the at() method on arrays, Object.hasOwn, or the ‘cause’ option on a new Error can be used with the new --target setting or with --lib es2022.
A feature that was present in the previous RC release but went undocumented was the suggestions for mismatched JSDoc parameter names. Developers can document parameters using an @param tag but when these fall out of date TypeScript editors will now provide suggestions for when parameter names don’t match between a function and its JSDoc comment.
Further code improvements have been made to classes; developers will now be able to write their constructor’s code before declaring super().
Activation playbook: Deliver data that powers impactful, game-changing campaigns
Bringing together data and technology to drive better business outcomesFree Download
In unpredictable times, a data strategy is key
Data processes are crucial to guide decisions and drive business growthFree Download
Achieving resiliency with Everything-as-a-Service (XAAS)
Transforming the enterprise IT landscapeFree Download
What is contextual analytics?
Creating more customer value in HR software applicationsFree Download