TypeScript 4.3 is out, featuring individual write types

Get a free Techzine subscription!

Microsoft announced the release of TypeScript 4.3, which comes with many updates including individual write types for properties, “–noImplicitOverride”, “override” and template string types improvements.  

With individual write types, developers can specify read and write types for properties. TypeScript uses the ‘read’ type exclusively when considering how two properties that share a name relate to each other.

The ‘Write’ type, however, is only taken into consideration when writing directly to each property. Microsoft also added an ‘override’ keyword in TypeScript 4.3.

What’s new and what does it do?

The introduction of the override keyword compensates for the problem that comes up when a user cannot make it clear whether they mean to add a new method or override the one already implemented. When the method is marked ‘override’, TypeScript will ensure that a method with the same name is in the base class as well.

With the ‘noImplicitOverride’ addition, any attempt to override any method from a superclass unless explicitly stated using an ‘override’ keyword, will become an error.

The template string improvements will allow TypeScript to handle the work to prove whether or not each part of the template string can successfully match so developers can mix strings with different subs as TypeScript determines if they’re compatible.

Other updates

There are added methods and accessors to elements that can be given #private#names to make them completely private when they run. The ‘ConstructorParemeters’ type helper works on ‘abstract’ classes, with inclusions for smarter type-narrowing logic on generic values, which allows the acceptance of more patterns.

Other additions include static index signatures, easier calculations in ‘–incremental’ and ‘–watch’ compilations, always-truthy promise checks, .tsbuildinfo size enhancements, editor support for @link tags and import statement completions, and more. All details about TypeScript 4.3 are available here.