-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Cannot use this
to index private or protected properties
#17362
Comments
I think this is expected given our rules on indexed access types - given that the indexed access operator is defined in terms of
So this will require adding an exception whereby private names are actually accessible when indexing |
@weswigham But So does indexing on classes have an exception for private/protected members, but that exception wasn't applied to |
As @weswigham noted, this is the intended behavior. it becomes very hard to reason about these types in higher order if you have to carry around a context to know if the name is visible or not. |
Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed. |
TypeScript Version: 2.4.1
Code
This works fine:
This works fine:
I expect this to work, but it does not work:
It fails with this error:
The text was updated successfully, but these errors were encountered: