Fix #9550: exclude 'this' type parameters from unusedParameters checks.

This commit is contained in:
Tetsuharu OHZEKI
2016-07-08 01:08:49 +09:00
committed by Mohamed Hegazy
parent 28938fbc30
commit 78e9fe2838
5 changed files with 300 additions and 0 deletions

View File

@@ -14563,6 +14563,7 @@ namespace ts {
const parameter = <ParameterDeclaration>local.valueDeclaration;
if (compilerOptions.noUnusedParameters &&
!isParameterPropertyDeclaration(parameter) &&
!parameterIsThisKeyword(parameter) &&
!parameterNameStartsWithUnderscore(parameter)) {
error(local.valueDeclaration.name, Diagnostics._0_is_declared_but_never_used, local.name);
}
@@ -14576,6 +14577,10 @@ namespace ts {
}
}
function parameterIsThisKeyword(parameter: ParameterDeclaration) {
return parameter.name && (<Identifier>parameter.name).originalKeywordKind === SyntaxKind.ThisKeyword;
}
function parameterNameStartsWithUnderscore(parameter: ParameterDeclaration) {
return parameter.name && parameter.name.kind === SyntaxKind.Identifier && (<Identifier>parameter.name).text.charCodeAt(0) === CharacterCodes._;
}