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

Error when accessing private property in object destructuring assignment with computed name #26572

Closed
ajafff opened this issue Aug 21, 2018 · 5 comments
Labels
Bug A bug in TypeScript Won't Fix The severity and priority of this issue do not warrant the time or complexity needed to fix it

Comments

@ajafff
Copy link
Contributor

ajafff commented Aug 21, 2018

TypeScript Version: 3.1.0-dev.20180818

Search Terms:

Code

class Foo {
    private prop = 1;
}
let prop: any;
({['prop']: prop} = new Foo());

Expected behavior:

No error on destructuring with computed property name.

Actual behavior:

Error on all statically known property names.

Playground Link:

Related Issues:
@andy-ms this was introduced in #26381 while fixing #26355

@RyanCavanaugh
Copy link
Member

I'm really tempted to Won't Fix this because the whole "private properties can be accessed via indexing" thing feels like something we only do because we did it in 0.8, and destructuring is new enough that it doesn't feel like this would break anything major.

@ajafff is this affecting you, or just something you noticed?

@RyanCavanaugh RyanCavanaugh added the Bug A bug in TypeScript label Aug 21, 2018
@ajafff
Copy link
Contributor Author

ajafff commented Aug 21, 2018

I just noticed that it's inconsistent with other element access with computed names.
If you say this is working as intended, that's fine for me. In that case you might want to consider reverting the recent change to destructuring BindingElement.

@RyanCavanaugh
Copy link
Member

Which part of it specifically?

@ajafff
Copy link
Contributor Author

ajafff commented Aug 21, 2018

#26360

@RyanCavanaugh RyanCavanaugh added the Won't Fix The severity and priority of this issue do not warrant the time or complexity needed to fix it label Aug 23, 2018
@RyanCavanaugh
Copy link
Member

Not going to keep around consistency of the sake of inconsistency.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Won't Fix The severity and priority of this issue do not warrant the time or complexity needed to fix it
Projects
None yet
Development

No branches or pull requests

2 participants