In addition to adding the literal types of templates, TypeScript 4.1 allows developers to rearrange the keys in the mapped types with a new as a clause. This new clause allows developers to take advantage of features like literal types in templates to create new property names based on the old ones. Keys can be filtered by producing never, which eliminates the need for developers to use an additional Omit helper type in some cases.
TypeScript 4.0, the current major release, was released in August.
Other features of TypeScript 4.1 include :
– L was able to use conditional recursive types : some restrictions are eased for conditional types e t these can now be referenced immediately in their branches, which facilitates writing aliases recursive types. Microsoft specifies that recursive types should be used responsibly and sparingly.
– A new flag – noUncheckedIndexedAccess provides a node where every property access or indexed access is considered potentially undefined. This flag can detect out-of-range errors but can create noise in a large number of codes. It is not automatically enabled by the –strict flag.
– The paths option can be used without baseUrl , to avoid a problem created by bad paths used by auto-imports.
– The functions default jsx and jsxs the framework React 17 are supported by two new options to the s options react-jsx and react-jsxdev the compiler jsx .
– In a breaking change, members marked as abstract can no longer be marked as asynchronous. In another breakthrough change, the resolution settings are no longer optional in Promise.
TypeScript 4.1 is accessible via NuGet or via the NPM command : npm install typescript .
Paul Krill / IDG (adaptation Jean Elyan)