mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-15 12:51:30 -05:00
Fix #9458: exclude parameters starting with underscore from unusedParamter checks
This commit is contained in:
@@ -14554,7 +14554,10 @@ namespace ts {
|
||||
const local = node.locals[key];
|
||||
if (!local.isReferenced) {
|
||||
if (local.valueDeclaration && local.valueDeclaration.kind === SyntaxKind.Parameter) {
|
||||
if (compilerOptions.noUnusedParameters && !isParameterPropertyDeclaration(<ParameterDeclaration>local.valueDeclaration)) {
|
||||
const parameter = <ParameterDeclaration>local.valueDeclaration;
|
||||
if (compilerOptions.noUnusedParameters &&
|
||||
!isParameterPropertyDeclaration(parameter) &&
|
||||
!parameterNameStartsWithUnderscore(parameter)) {
|
||||
error(local.valueDeclaration.name, Diagnostics._0_is_declared_but_never_used, local.name);
|
||||
}
|
||||
}
|
||||
@@ -14567,6 +14570,10 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function parameterNameStartsWithUnderscore(parameter: ParameterDeclaration) {
|
||||
return parameter.name && parameter.name.kind === SyntaxKind.Identifier && (<Identifier>parameter.name).text.charCodeAt(0) === CharacterCodes._;
|
||||
}
|
||||
|
||||
function checkUnusedClassMembers(node: ClassDeclaration | ClassExpression): void {
|
||||
if (compilerOptions.noUnusedLocals && !isInAmbientContext(node)) {
|
||||
if (node.members) {
|
||||
|
||||
Reference in New Issue
Block a user