Do not report error on implicityly any binding element if it is from parameter destructuring of private method

Fixes #8002
This commit is contained in:
Sheetal Nandi
2016-04-11 15:22:57 -07:00
parent 9d35468d17
commit b24883304b
4 changed files with 61 additions and 20 deletions

View File

@@ -2843,7 +2843,7 @@ namespace ts {
if (isBindingPattern(element.name)) {
return getTypeFromBindingPattern(<BindingPattern>element.name, includePatternInType);
}
if (compilerOptions.noImplicitAny) {
if (compilerOptions.noImplicitAny && canReportImplicitAnyError(element)) {
reportImplicitAnyError(element, anyType);
}
return anyType;
@@ -2936,14 +2936,18 @@ namespace ts {
// Report implicit any errors unless this is a private property within an ambient declaration
if (reportErrors && compilerOptions.noImplicitAny) {
const root = getRootDeclaration(declaration);
if (!isPrivateWithinAmbient(root) && !(root.kind === SyntaxKind.Parameter && isPrivateWithinAmbient(root.parent))) {
if (canReportImplicitAnyError(declaration)) {
reportImplicitAnyError(declaration, type);
}
}
return type;
}
function canReportImplicitAnyError(declaration: VariableLikeDeclaration) {
const root = getRootDeclaration(declaration);
return !isPrivateWithinAmbient(root) && !(root.kind === SyntaxKind.Parameter && isPrivateWithinAmbient(root.parent));
}
function getTypeOfVariableOrParameterOrProperty(symbol: Symbol): Type {
const links = getSymbolLinks(symbol);
if (!links.type) {