Skip to content

Commit 13e85ac

Browse files
committed
add more modifiers
1 parent d411fa3 commit 13e85ac

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/services/codefixes/fixUnusedIdentifier.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,9 +200,12 @@ namespace ts.codefix {
200200

201201
function tryDeleteParameter(changes: textChanges.ChangeTracker, sourceFile: SourceFile, p: ParameterDeclaration, checker: TypeChecker, sourceFiles: ReadonlyArray<SourceFile>, isFixAll: boolean): void {
202202
if (mayDeleteParameter(p, checker, isFixAll)) {
203-
const privateModifier = findModifier(p, SyntaxKind.PrivateKeyword);
204-
if (privateModifier) {
205-
changes.deleteModifier(sourceFile, p.modifiers![0]);
203+
const modifiers: Modifier["kind"][] = [SyntaxKind.PrivateKeyword, SyntaxKind.ProtectedKeyword, SyntaxKind.PublicKeyword, SyntaxKind.ReadonlyKeyword];
204+
const foundModifiers = modifiers.map(modifier => findModifier(p, modifier)).filter(modifier => modifier !== undefined);
205+
if (foundModifiers.length > 0) {
206+
foundModifiers.forEach(modifier => {
207+
changes.deleteModifier(sourceFile, modifier!);
208+
});
206209
}
207210
else {
208211
changes.delete(sourceFile, p);

tests/cases/fourslash/codeFixUnusedIdentifier_parameter_modifier.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
////export class Example {
77
//// prop: any;
8-
//// constructor(private arg: any) {
8+
//// constructor(private readonly arg: any) {
99
//// this.prop = arg;
1010
//// }
1111
////}

0 commit comments

Comments
 (0)