diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index fc79da502c8..7b5fd18920e 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2843,7 +2843,7 @@ namespace ts { if (isBindingPattern(element.name)) { return getTypeFromBindingPattern(element.name, includePatternInType); } - if (compilerOptions.noImplicitAny && canReportImplicitAnyError(element)) { + if (compilerOptions.noImplicitAny && !declarationBelongsToPrivateAmbientMember(element)) { reportImplicitAnyError(element, anyType); } return anyType; @@ -2936,16 +2936,17 @@ namespace ts { // Report implicit any errors unless this is a private property within an ambient declaration if (reportErrors && compilerOptions.noImplicitAny) { - if (canReportImplicitAnyError(declaration)) { + if (!declarationBelongsToPrivateAmbientMember(declaration)) { reportImplicitAnyError(declaration, type); } } return type; } - function canReportImplicitAnyError(declaration: VariableLikeDeclaration) { + function declarationBelongsToPrivateAmbientMember(declaration: VariableLikeDeclaration) { const root = getRootDeclaration(declaration); - return !isPrivateWithinAmbient(root) && !(root.kind === SyntaxKind.Parameter && isPrivateWithinAmbient(root.parent)); + const memberDeclaration = root.kind === SyntaxKind.Parameter ? root.parent : root; + return isPrivateWithinAmbient(memberDeclaration); } function getTypeOfVariableOrParameterOrProperty(symbol: Symbol): Type {