Skip to content

Nested destructuring with private and protected members #26760

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

Closed
princed opened this issue Aug 30, 2018 · 1 comment
Closed

Nested destructuring with private and protected members #26760

princed opened this issue Aug 30, 2018 · 1 comment
Assignees
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue

Comments

@princed
Copy link

princed commented Aug 30, 2018

TypeScript Version:
3.0.3
3.1.0-dev.20180829

Search Terms:
private fields destructuring
private members destructuring

Code

class Foo {
    private prop;
}
const foo = new Foo();
const bar = { foo };

// Errors
foo.prop;
const { prop: prop1 } = foo; 

// No error
const { foo: { prop: prop2 } } = bar;

Expected behavior:
Nested destructuring of private and protected members causes an error

Actual behavior:
It doesn't

Playground Link:
https://www.typescriptlang.org/play/index.html#src=class%20Foo%20%7B%0D%0A%20%20%20%20private%20prop%3B%0D%0A%7D%0D%0Aconst%20foo%20%3D%20new%20Foo()%3B%0D%0Aconst%20bar%20%3D%20%7B%20foo%20%7D%3B%0D%0A%0D%0A%2F%2F%20Errors%0D%0Afoo.prop%3B%0D%0Aconst%20%7B%20prop%3A%20prop1%20%7D%20%3D%20foo%3B%20%0D%0A%0D%0A%2F%2F%20No%20error%0D%0Aconst%20%7B%20foo%3A%20%7B%20prop%3A%20prop2%20%7D%20%7D%20%3D%20bar%3B%0D%0A%20

Related Issues:
#7124

@ghost ghost added the Bug A bug in TypeScript label Aug 30, 2018
@RyanCavanaugh RyanCavanaugh added this to the TypeScript 3.3 milestone Oct 9, 2018
@rbuckton rbuckton self-assigned this Nov 16, 2018
@ghost
Copy link

ghost commented Nov 17, 2018

Seems fixed now. Probably by #28562.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue
Projects
None yet
Development

No branches or pull requests

3 participants