Skip to content

Error when destructuring private property in a parameter#28562

Merged
2 commits merged into
masterfrom
destructureParameterPrivateProperty
Nov 16, 2018
Merged

Error when destructuring private property in a parameter#28562
2 commits merged into
masterfrom
destructureParameterPrivateProperty

Conversation

@ghost
Copy link
Copy Markdown

@ghost ghost commented Nov 15, 2018

Previously the check was only done if parent.initializer existed, which meant it worked for variable declarations but not for parameters.

@ghost ghost requested a review from sheetalkamat November 16, 2018 00:04
@ghost ghost merged commit e0dca0b into master Nov 16, 2018
@ghost ghost deleted the destructureParameterPrivateProperty branch November 16, 2018 20:47
@princed
Copy link
Copy Markdown

princed commented Nov 17, 2018

Don't you want to add a test for this one?

@ghost
Copy link
Copy Markdown
Author

ghost commented Nov 17, 2018

See the bottom of privateProtectedMembersAreNotAccessibleDestructuring.ts.

@princed
Copy link
Copy Markdown

princed commented Nov 17, 2018

Oh, I'm sorry, I was going to comment in #26760, so there would be nested destructuring context.

I thought we could add something like this to privateProtectedMembersAreNotAccessibleDestructuring.ts:

let nested = { k };
let {k: {priv: an, prot: bn, privateMethod: pmn}} = nested; // error

What do you think?

@ghost
Copy link
Copy Markdown
Author

ghost commented Nov 17, 2018

PRs accepted. 👍

@microsoft microsoft locked as resolved and limited conversation to collaborators Oct 21, 2025
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants