Microsoft announced the release of TypeScript 4.3, which adds many new features such as separate write types on properties, ‘override’ and the ‘–noImplicitOverride’ flag, template string type improvements and more.
With separate write types, developers can specify types for reading and writing to properties. TypeScript will only use the “reading” type when considering how two properties with the same name relate to each other. On the other hand, “writing” types are only considered when directly writing to a property.
RELATED CONTENT: TypeScript Handbook gets a rework
Microsoft also added the ‘override’ keyword in TypeScript 4.3 to overcome the issue that arises when a user can’t make it clear whether they mean to add a new method or to override an existing one. When a method is marked with ‘override,’ TypeScript will make sure that a method with the same name exists in the base class.
Also, with the ‘noImplicitOverride’ flag, it becomes an error to override any method from a superclass unless one explicitly uses an ‘override’ keyword.
As part of the new template string improvements, TypeScript will now handle the work to prove whether or not each part of a template string can successfully match so that developers can now mix template strings with different substitutions while TypeScript figures out if they’re compatible.
TypeScript 4.3 also added methods and accessors to the elements that can be given #private #names to make them truly private at run-time.
In the new version, the ‘ConstructorParameters’ type helper now works on ‘abstract’ classes and TypeScript now includes slightly smarter type-narrowing logic on generic values, which allows it to accept more patterns.
Other updates include always-truthy promise checks, static index signatures, .tsbuildinfo size improvements, lazier calculations in ‘–incremental’ and ‘–watch’ compilations, import statement completions, editor support for @link tags and more.
Additional details on all of the new features in TypeScript 4.3 are available here.