TypeScript 4.1 Is Now Available

Microsoft has released TypeScript 4.1that brings exciting new features, new checking flags, editor productivity updates, and speed enhancement.

Recently, Microsoft released the latest version of TypeScript, 4.1.

TypeScript is a language that builds on JavaScript by adding syntax for type declarations and annotations. TypeScript compiler uses this syntax to type-check your code, and then output clean readable JavaScript that can run on lots of different runtimes. 

TypeScript 4.1 brings some exciting new features, new checking flags, editor productivity updates, and speed improvements; including Template Literal Types, Key Remapping in Mapped Types, Recursive Conditional Types, and React 17 JSX Factories.

Source: Microsoft

The release also features --noUncheckedIndexedAccess, paths without baseUrl, and checkJs Implies allowJs. You now also get editor support for the JSDoc @see Tag.

The new template literal string type has the same syntax as template literal strings in JavaScript, but is used in type positions. When used with concrete literal types, it produces a new string literal type by concatenating the contents. If you have unions in substitution position,  it produces the set of every possible string literal that could be represented by each union member.

Version 4.1 also allows you to re-map keys in mapped types with a new as clause. New as clause allows you to leverage features like template literal types to easily create property names based off of old ones. You can even filter out keys by producing never. You do not have to use an extra Omit helper type in some cases.

4.1 also eases some restrictions on conditional types. Conditional types can now immediately reference themselves within their branches, making it easier to write recursive type aliases.

TypeScript 4.1 also brings a new flag called --noUncheckedIndexedAccess. Under this new mode, every property access  or indexed access  is considered potentially undefined.

For additional details, you can visit the official announcement here.



Next Recommended Reading Android Studio 4.1 Is Now Available