Correct codefix by removing private modifier
In case of private attribute and private constructor parameter with assignment in the constructor body, the parameter is flagged as unused. This is caused by the private modifier which is shadowed by the explicity assignment in the body. This commit updates the codefix to just remove the private modifier in this cases. Closes #24931
This commit is contained in:
parent
6b641de465
commit
e6e71978df
|
@ -200,8 +200,14 @@ namespace ts.codefix {
|
|||
|
||||
function tryDeleteParameter(changes: textChanges.ChangeTracker, sourceFile: SourceFile, p: ParameterDeclaration, checker: TypeChecker, sourceFiles: ReadonlyArray<SourceFile>, isFixAll: boolean): void {
|
||||
if (mayDeleteParameter(p, checker, isFixAll)) {
|
||||
changes.delete(sourceFile, p);
|
||||
deleteUnusedArguments(changes, sourceFile, p, sourceFiles, checker);
|
||||
const privateModifier = ts.findModifier(p, ts.SyntaxKind.PrivateKeyword);
|
||||
if (privateModifier) {
|
||||
changes.deleteModifier(sourceFile, p.modifiers![0]);
|
||||
}
|
||||
else {
|
||||
changes.delete(sourceFile, p);
|
||||
deleteUnusedArguments(changes, sourceFile, p, sourceFiles, checker);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue