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

Emit actually-private members for classes, for runtime. #28291

Closed
4 tasks
trusktr opened this issue Nov 1, 2018 · 2 comments
Closed
4 tasks

Emit actually-private members for classes, for runtime. #28291

trusktr opened this issue Nov 1, 2018 · 2 comments
Labels
Question An issue which isn't directly actionable in code

Comments

@trusktr
Copy link
Contributor

trusktr commented Nov 1, 2018

Suggestion

I already read the FAQ regarding this, but private members are possible, and it'd be nice to (optionally) have them at runtime.

Use Cases

So people interacting with your code at runtime experience the restrictions we desired them to have. They might not use TypeScript.

Examples

See lowclass (look at the extensive tests files showing all sorts of uses of runtime public/protected/private members). The implementation is not long, and some features can be omitted in order just to have the minimal protected/private functionality.

It uses WeakMaps to store protected/private state.

Babel also has private member feature.

Checklist

My suggestion meets these guidelines:

  • This wouldn't be a breaking change in existing TypeScript / JavaScript code
    • It will break JavaScript code that is improperly relying on emitted internals that should be private.
  • This wouldn't change the runtime behavior of existing JavaScript code
    • Same as previous.
  • This could be implemented without emitting different JS based on the types of the expressions
    • emits different runtime code
  • This isn't a runtime feature (e.g. new expression-level syntax)
    • it is basically a runtime feature, doesn't change anything related to types.
@trusktr trusktr changed the title Emit actually private members. Emit actually-private members for classes, for runtime. Nov 1, 2018
@weswigham weswigham added the Question An issue which isn't directly actionable in code label Nov 1, 2018
@weswigham
Copy link
Member

You should be monitoring #9950 for implementation of the official ECMAScript runtime privacy proposal.

@trusktr
Copy link
Contributor Author

trusktr commented Nov 1, 2018

Oh sweeet, and sorry. Closing this one.

@trusktr trusktr closed this as completed Nov 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Question An issue which isn't directly actionable in code
Projects
None yet
Development

No branches or pull requests

2 participants