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


New Raspberry Pi Website
07/10/2021

There's now a second website for Raspberry Pi. The raspberrypi.com site is the new home of Raspberry Pi Trading, while the original site, raspberrypi.org, is where you'll find the Raspberry Pi Foundat [ ... ]



Questions Raised About .NET Foundation
06/10/2021

A member of the .NET Foundation board who resigned, disillusioned with an organization that doesn't appear to support its members or foster open source sustainability, has made his views public.


More News

square

 



 

Comments




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