Skip to content

Stop destructuring private properties #7262

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

Merged
merged 4 commits into from
Feb 26, 2016

Conversation

sandersn
Copy link
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.
@@ -2642,6 +2643,11 @@ namespace ts {
error(name, Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), declarationNameToString(name));
return unknownType;
}

const property = getPropertyOfType(parentType, text);
if (parent && parent.initializer && property && getParentOfSymbol(property)) {
Copy link
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
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
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
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
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