Class fields are starting to appear in browsers and transpilers. Even if you know how to use them, you may be wondering what decisions went into their design. We’re joined this week by Rob Palmer of Bloomberg and a TC39 representative as well as Daniel Ehrenberg of Igalia and a co-author of the class field proposals.
We learn about the history of class fields which go all the way back to ES2, why many potential approaches to private fields fail to offer strong encapsulation, and why the # symbol was used as a prefix for private fields. We wrap things up with a discussion of the impact of private fields on library and framework authors, what fears developers have about private fields, and the work being done to educate developers on these new language additions.
Rob Palmer on Twitter
Daniel Ehrenberg on Twitter
Daniel is a partner at Igalia, an open source consultancy specialized in the development of innovative projects and solutions. He works on TC39 including the private fields proposal.
Below are links to the resources and topics mentioned during this episode.
TC39 proposal for Class Fields
MDN documentation on classes
Axel Rauschmeyer’s explainer on class fields
Google developer update on class fields
Babel plugin for Class Fields
TypeScript (work-in-progress) support for Class Fields
Cheng Lou’s talk on why we lower common abstractions into the language
The new TC39 website listing all proposals