Skip to content

Commit ee310a4

Browse files
committed
move static flag predicate before get container
1 parent 56d0424 commit ee310a4

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/compiler/checker.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17110,8 +17110,7 @@ namespace ts {
1711017110
// allow PropertyAccessibility if context is in function with this parameter
1711117111
// static member access is disallow
1711217112
let thisParameter: ParameterDeclaration | undefined;
17113-
const thisContainer = getThisContainer(node, /* includeArrowFunctions */ false);
17114-
if (flags & ModifierFlags.Static || !thisContainer || !isFunctionLike(thisContainer) || !(thisParameter = getThisParameter(thisContainer)) || !thisParameter.type) {
17113+
if (flags & ModifierFlags.Static || !(thisParameter = getThisParameterFromNodeContext(node)) || !thisParameter.type) {
1711517114
error(errorNode, Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses, symbolToString(prop), typeToString(getDeclaringClass(prop) || type));
1711617115
return false;
1711717116
}
@@ -17134,6 +17133,11 @@ namespace ts {
1713417133
return true;
1713517134
}
1713617135

17136+
function getThisParameterFromNodeContext (node: Node) {
17137+
const thisContainer = getThisContainer(node, /* includeArrowFunctions */ false);
17138+
return thisContainer && isFunctionLike(thisContainer) ? getThisParameter(thisContainer) : undefined;
17139+
}
17140+
1713717141
function symbolHasNonMethodDeclaration(symbol: Symbol) {
1713817142
return forEachProperty(symbol, prop => {
1713917143
const propKind = getDeclarationKindFromSymbol(prop);

0 commit comments

Comments
 (0)