In addition to introducing template literal types, TypeScript 4.1 lets developers re-map keys in mapped types with a new
as clause. This new clause lets developers leverage features like template literal types to create new property names based on old ones. Keys can be filtered by producing
never, saving developers from having to use an extra
Omit helper type in some cases.
TypeScript 4.0, the current major release, arrived in August. Other capabilities in TypeScript 4.1 include:
- With a recursive conditional types capability, some restrictions are eased on conditional types, which are now able to immediately reference themselves within their branches, making it easier to write recursive type aliases. Microsoft cautions 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 catch out-of-bounds errors but might be noisy for a lot of code. It is not automatically enabled by the
pathsoption can be used without
baseUrl, to avoid an issue in which poor paths have been used by auto-imports.
checkJs, which caused friction.
- The React 17 framework’s
jsxsfactory functions are supported through two new options for the
- The JSDoc tag
- In a breaking change, members marked as
abstractcan no longer be marked as
async. In another breaking change,
resolveparameters are no longer optional in
TypeScript 4.1 can be accessed through NuGet or NPM:
npm install typescript