-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Conversation
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)) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed the check
👍 |
…operties Stop destructuring private properties
Fixes #7124
It does this by calling
checkClassPropertyAccess
fromgetTypeFromBindingElement
. I don't think this is a good idea, so I'm going to go look whether I can call it fromcheckVariableLikeDeclaration
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.