Add support for ES.Next private methods and private accessor properties · Issue #39066 · microsoft/TypeScript (original) (raw)
Search Terms
TypeScript 3.9, TC39, Stage 3, ES.Next, private methods, private accessor properties, #methods
Suggestion
Private methods and private accessor properties (both static and instance) are currently at stage 3 of the TC39 working group. They will hopefully be part of the ES2021 standard. The Google Javascript V8 engine in Version 8.3 and Node.js 13.2+ support these features already if one uses the flag --harmony-private-methods
. Google Chrome 84, and Google Javascript V8 8.4 engine will support them officially (see compatibility table). Node.js will probably follow soon after the Google Chome 84 release.
Use Cases
TC39 private methods and private accessor properties offer standard compatibility with future Javascript versions.
Examples
class newFeatures { static #classMethod(): void { } static get #classPropertyAccessor(): number { return 0; } static set #classPropertyAccessor(v: number): void { } #instanceMethod(): void { } get #instancePropertyAccessor(): number { return 0; } set #instancePropertyAccessor(v: number): void { } }
Checklist
My suggestion meets these guidelines:
- This wouldn't be a breaking change in existing TypeScript/JavaScript code
- This wouldn't change the runtime behavior of existing JavaScript code
- This could be implemented without emitting different JS based on the types of the expressions
- This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
- This feature would agree with the rest of TypeScript's Design Goals.