mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-16 07:13:45 -05:00
Merge pull request #9557 from saneyuki/fix-unusedparam-this
Fix #9550: exclude 'this' type parameters from unusedParameters checks.
This commit is contained in:
@@ -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._;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user