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
TypeScript Version:
3.0.3
3.1.0-dev.20180829
Search Terms:
private fields destructuring
private members destructuring
Code
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