TypeScript 3.8 beta adds support for ECMAScript private fields
Released on January 10, 2020, TypeScript 3.8 Beta includes features that users can expect to find in the final version. Give the beta a try and familiarize yourself with what is coming in the final release.
This version includes the support and collaborative efforts of the Bloomberg engineering team.
v3.8 beta features
Daniel Rosenwasser, TypeScript program manager, dives deep into the new features in the Microsoft announcement post.
Take a look at the recent arrival. Some of the highlights of v3.8 beta include:
Thanks to contributions from Bloomberg, support for ECMAScript’s private fields arrives. It is currently in the third stage of development, which indicates that further refinement and feedback are needed before it is included in the formal ECMAScript standard.
Rosenwasser notes that with the introduction of private fields comes a few new rules.
- Private fields start with a
#character. Sometimes we call these private names.
- Every private field name is uniquely scoped to its containing class.
- TypeScript accessibility modifiers like
privatecan’t be used on private fields.
- Private fields can’t be accessed or even detected outside of the containing class – even by JS users! Sometimes we call this hard privacy.
View more information about public and private class fields in the proposal.