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:
Markus Wolf 2018-10-19 15:55:34 +02:00
parent 6b641de465
commit e6e71978df
No known key found for this signature in database
GPG key ID: 46051C9BE153B7A5

View file

@ -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);
}
}
}