Skip to content
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

Allow protected members to be accessed within the enclosing class #60001

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Andarist
Copy link
Contributor

fixes #59989

@typescript-bot typescript-bot added the For Backlog Bug PRs that fix a backlog bug label Sep 18, 2024
@@ -33868,7 +33868,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
// get the original type -- represented as the type constraint of the 'this' type
containingType = (containingType as TypeParameter).isThisType ? getConstraintOfTypeParameter(containingType as TypeParameter)! : getBaseConstraintOfType(containingType as TypeParameter)!; // TODO: GH#18217 Use a different variable that's allowed to be undefined
}
if (!containingType || !hasBaseType(containingType, enclosingClass)) {
if (!containingType || !hasBaseType(containingType, enclosingClass) && !isNodeWithinClass(location, getClassLikeDeclarationOfSymbol(getParentOfSymbol(prop)!)!)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

the added check is the same one as for private properties a couple of lines above this (in this function)

@Andarist Andarist force-pushed the fix/protected-members-within-class branch from 71bbed7 to f00d00b Compare September 19, 2024 16:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For Backlog Bug PRs that fix a backlog bug
Projects
Status: Not started
Development

Successfully merging this pull request may close these issues.

Cannot access protected field but private field inside nested class
2 participants