TypeScript 4.3 Adds Separate Property Write Types
Written by Kay Ewbank   
Tuesday, 15 June 2021

TypeScript 4.3 has been released with enhancements including separate write types on properties, template string type improvements, and #private support for EMCAScript class elements.

TypeScript is a superset of JavaScript that adds optional static types which can be checked by the TypeScript compiler to catch common errors in your programs.

typescriptlogo

JavaScript APIs often convert values that are passed in before storing them, but in previous releases of TypeScript developers had no easy way to be specific about the types being passed to and from such APIs. TypeScript 4.3 now allows you to specify types for reading and writing to properties, including new syntax for interfaces/object types to support different reading/writing types on properties. The developers point out that the type for reading a property has to be assignable to the type that you’re writing.

Template string types, which were added recently to TypeScript to provide types that construct new string-like types by concatenating or by matching the patterns of other string-like types, have also received work in this release. The improvements start by changing when TypeScript will infer a template string type. In the new release, when TypeScript sees that you're passing a template string to something that takes a literal type, it will try to give that expression a template type. Another change means that TypeScript is better at relating to and inferring between different template string types.

A third improvement is that TypeScript 4.3 expands which ECMAScript class elements elements can be given #private #names to make them truly private at run-time. In addition to properties, methods and accessors can also be given private names.

Other improvements include changes to the ConstructorParameters type helper so it now works on abstract classes, and smarter type-narrowing logic on generic values. This allows TypeScript to accept more patterns, and sometimes even catch mistakes.

TypeScript 4.3 is available now.

typescriptlogo

More Information

TypeScript On NuGet

TypeScript On GitHub

Related Articles

TypeScript 4.2 Release Candidate Available

New TypeScript Website Launched

TypeScript 4.1 Adds Temporal Literal Types

TypeScript 3.6 Generators Get Stricter

TypeScript 3.5 Adds Smart Select 

TypeScript 3.2 Gets Stricter Checking

TypeScript 3.1 Adds Mappable Tuples

TypeScript 3.0 Adds Project References

TypeScript Adds Unused Span Reporting

TypeScript Adds Conditional Types

 

To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on Twitter, Facebook or Linkedin.

Banner


Google Releases Gemini 2 And Jules Code Agent
18/12/2024

Google has announced an updated version of Gemini, saying that Gemini 2.0 Flash Experimental will "enable even more immersive and interactive applications", along with new coding agents that can take  [ ... ]



Visual Studio 17.12 Released Along With Aspire
25/11/2024

Visual Studio 2022 v17.12 is now available. The release can be used for .NET 9 projects and has a range of other improvements.


More News

espbook

 

Comments




or email your comment to: comments@i-programmer.info