diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 1cebd469388..ff248d75941 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -11544,8 +11544,23 @@ namespace ts { const declaringClassDeclaration = getClassLikeDeclarationOfSymbol(declaration.parent.symbol); const declaringClass = getDeclaredTypeOfSymbol(declaration.parent.symbol); - // A private or protected constructor can only be instantiated within it's own class + // A private or protected constructor can only be instantiated within its own class or a static method of a subclass if (!isNodeWithinClass(node, declaringClassDeclaration)) { + const containingFunction = getContainingFunction(node); + const containingClass = getContainingClass(node); + if (containingClass) { + const containingType = getTypeOfNode(containingClass); + const baseTypes = getBaseTypes(containingType); + if (baseTypes.length) { + const baseType = baseTypes[0]; + if (containingFunction && + containingFunction.flags & NodeFlags.Static && + flags & NodeFlags.Protected && + baseType.symbol === declaration.parent.symbol) { + return true; + } + } + } if (flags & NodeFlags.Private) { error(node, Diagnostics.Constructor_of_class_0_is_private_and_only_accessible_within_the_class_declaration, typeToString(declaringClass)); }