New TypeScript 4.1 version released

TypeScript 4.1 release

TypeScript is an extended version of JavaScript, whose main goal is to simplify the development of large JS applications. This language adds a lot of new principles-classes, generics, interfaces, static types, which allows developers to use different tools, such as a static analyzer or code refactoring.

On 20th November, Daniel Rosenwasser announced the release of TypeScript 4.1 and all changes in the new version. The update includes template literal types and many other improvements.

In TypeScript 4.1, Template Literal Types were added. They allow you to describe types that consist of multiple string literal types. They also allow you to “extract” string literals from other literals at the type level. As part of this feature, new utility types were added for manipulating strings — Uppercase, Lowercase, Capitalize, Uncapitalize.

With the new version, you can remap keys in mapped types. You can use this to filter properties of object types or create new object types with keys that use literal template types.

Full support for recursive conditional types is now available. It is useful to describe the types of recursive structures. Developers advise not to overuse this feature, as it can negatively affect the performance of type checking.

Added the –noUncheckedIndexedAccess flag to more strictly check access to array elements or object properties. The paths parameter can now be used without specifying baseUrl. Now you don’t need to enable allowJs when using the checkJs option. Added support for JSX and jsxs factories from React 17 (used by transpilers).

There are a few breaking changes. Conditional spreads create optional properties. In a breaking change, members marked as abstract can no longer be marked as async. In another breaking change, resolve parameters are no longer optional in Promise.

If the false position in a conditional expression returns the type any/unknown, then any/unknown will be extended to the entire expression.

Recommended Articles

Share
Tweet
Pin
Share
Share