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

TSification: mark fields as private/protected #2300

Closed
alexeagle opened this issue Jun 2, 2015 · 6 comments
Closed

TSification: mark fields as private/protected #2300

alexeagle opened this issue Jun 2, 2015 · 6 comments
Labels
effort1: hours feature Issue that requests a new feature help wanted An issue that is suitable for a community contributor (based on its complexity/scope).

Comments

@alexeagle
Copy link
Contributor

We have a convention from AtScript of prefixing privates with underscore. This is also needed so the ts2dart emit produces "private" fields/methods in Dart.

We should mark these actually private, so TypeScript can enforce it.

Notes:

  • could use ts2dart as a linter to warn if a field in .ts has underscore prefix but isn't private
  • sometimes we access these variables from outside the class, pretending that the semantics of underscore-prefix is that it's "module-private"
@mhevery mhevery added feature Issue that requests a new feature comp: build/pipeline effort1: hours labels Jun 3, 2015
@vicb
Copy link
Contributor

vicb commented Jun 3, 2015

Note that some fields are _prefixed but not private according to the TS definition: they are accessed by classes/functions in the same file.

I have used this convention at a few places (and I think other have too) having in mind the Dart definition of private, ie private member are library private in Dart (they can be accessed from within the same library which is essentially the same file in Angular as we use a 1-1 mapping).

Edit: Oops didn't read your comment until the end !

@mhevery mhevery added the help wanted An issue that is suitable for a community contributor (based on its complexity/scope). label Jun 19, 2015
@willbuck
Copy link

I wouldn't mind taking a crack at this, I'll get started and check back here if I have questions :)

@alexeagle
Copy link
Contributor Author

See dart-archive/ts2dart#278
We have an option you could enable:
https://github.com/angular/angular/compare/master...alexeagle:underscore?expand=1#diff-cb068e9a6a1837586e67d28648bf2067R18

But this enforces too much. We don't have a good answer for marking fields/methods in TS as 'may be accessed anywhere in this file', we cannot currently make them private.

In the meantime, a good next step would be a tslint check in the angular repo that any private method starts with underscore. It's better to enforce this way since TS-only contributors will still have the enforcement.

@gilamran
Copy link

@alexeagle I've created a PR on the lint thing: #5043

@mhevery
Copy link
Contributor

mhevery commented Jul 1, 2016

This is obsolete, and no longer relevant / actionable. To keep our issues clean, we are aggressively closing them.

@mhevery mhevery closed this as completed Jul 1, 2016
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
effort1: hours feature Issue that requests a new feature help wanted An issue that is suitable for a community contributor (based on its complexity/scope).
Projects
None yet
Development

No branches or pull requests

6 participants