Skip to content

Stop destructuring private properties#7262

Merged
sandersn merged 4 commits into
masterfrom
stop-destructuring-private-properties
Feb 26, 2016
Merged

Stop destructuring private properties#7262
sandersn merged 4 commits into
masterfrom
stop-destructuring-private-properties

Conversation

@sandersn
Copy link
Copy Markdown
Member

Fixes #7124

It does this by calling checkClassPropertyAccess from getTypeFromBindingElement. I don't think this is a good idea, so I'm going to go look whether I can call it from checkVariableLikeDeclaration or something similar.

The third commit changes checkClassPropertyAccess to tighten the error span. You should review the 3 commits separately.

Update: Now it's called from checkVariableLikeDeclaration instead.

This is probably the wrong place (a get- function rather than a check-
function), but it's a starting point since it passes all tests.
Comment thread src/compiler/checker.ts Outdated
}

const property = getPropertyOfType(parentType, text);
if (parent && parent.initializer && property && getParentOfSymbol(property)) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

parent should always be defined for a binding pattern.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you need getParentOfSymbol?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

checkClassPropertyAccess needs it, but sometimes it's undefined.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed the check

@DanielRosenwasser
Copy link
Copy Markdown
Member

👍

sandersn added a commit that referenced this pull request Feb 26, 2016
…operties

Stop destructuring private properties
@sandersn sandersn merged commit 5e53ba0 into master Feb 26, 2016
@sandersn sandersn deleted the stop-destructuring-private-properties branch February 26, 2016 23:06
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
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.

3 participants