TypeScript version 4.7 beta launch leave developers 'delighted' with new features
A host of new features are headed to the programming language which is undergoing a period of rapid development
Microsoft has released the latest version of TypeScript (4.7) in beta and introduced various new features that have met with excitement from the language’s programmers.
The tech giant has continued its rapid development with the programming language after only having released the previous stable version (4.6) in March this year.
ESM is a module format Node.js has been working to implement for years but development has been “very difficult”, according to Microsoft, since Node is built on an older system called CommonJS (CJS) which uses modules differently.
TypeScript 4.5 previously introduced nightly-only support for ESM in Node to get feedback from users and with version 4.7, support for interoperability between ESM and CJS is now available in TypeScript.
Some developers have expressed concern about how they will be forced to implement ESM in existing projects, despite widespread excitement.
Developers have called this confusing, and Microsoft said the re-writing process “might feel cumbersome at first”, but in many cases, TypeScript tooling like auto-imports and path completion will make the change automatically for developers.
TypeScript version 4.7 also introduces instantiation expressions which allow developers to specify type arguments for generic functions or constructors without calling them.
Developers can now create specific instantiations of generic class constructors or functions using a new expression syntax, feeding them type arguments directly.
When a function or constructor is given one or more type arguments, they essentially make an alias of the original and replace the corresponding type parameters with the provided type arguments while dropping all the other signatures as it will assume these are not meant to be used.
Programmers also stand to benefit from variance annotations for type parameters, which bring the potential for clearer, more explicitly typed code for outsiders to more easily see how a type parameter is used. It can be difficult to understand if a type should be read, written, or both, especially with more complex types, so it stands to benefit teams working on a complex codebase.
Microsoft also said the feature can also bring performance benefits since TypeScript can type-check larger structural types with more precision and speed.
Full details on the host of new features coming to TypeScript can be found in Microsoft’s detailed release notes.
Accelerating AI modernisation with data infrastructure
Generate business value from your AI initiativesFree Download
Recommendations for managing AI risks
Integrate your external AI tool findings into your broader security programsFree Download
Modernise your legacy databases in the cloud
An introduction to cloud databasesFree Download
Powering through to innovation
IT agility drive digital transformationFree Download