Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adopt ECMAScript Private Fields #3980

Closed
kitsonk opened this issue Feb 12, 2020 · 0 comments · Fixed by #4498
Closed

Adopt ECMAScript Private Fields #3980

kitsonk opened this issue Feb 12, 2020 · 0 comments · Fixed by #4498

Comments

@kitsonk
Copy link
Contributor

kitsonk commented Feb 12, 2020

We should adopt ECMAScript private fields in the internal code within Deno and in std. We have a couple of different patterns in the code base in regards to this (TypeScript private and using WeakMaps in Events) and should adopt a consistent mechanism which provides us with the runtime privacy of data. We have a 3rd pattern where we have marked some fields as private, but they are defined with a symbol to make it easy to utilise an interator interface. We might reconsider dropping the private keyword.

Private fields do not apply to methods (fields are not part of prototype, while methods are), so not all of our use of the private keyword could be easily addressed (I am not too personally keen on turning methods into fields, as having them part of the prototype is far more efficient).

TypeScript 3.8 will support ECMAScript private fields, V8 already supports them. But, right now prettier and dprint do not. We still use prettier for formatting our internal code, and dprint for deno fmt.

Refs #3937
Refs prettier/prettier#7263
Refs dsherret/dprint#91

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant