Skip to content

Commit c06849a

Browse files
authored
fix(47787): show QF to delete parameter in getter (#47797)
1 parent c5b1011 commit c06849a

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

src/services/codefixes/fixUnusedIdentifier.ts

+4
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,10 @@ namespace ts.codefix {
316316
// Setter must have a parameter
317317
return false;
318318

319+
case SyntaxKind.GetAccessor:
320+
// Getter cannot have parameters
321+
return true;
322+
319323
default:
320324
return Debug.failBadSyntaxKind(parent);
321325
}

src/services/formatting/smartIndenter.ts

+2
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,8 @@ namespace ts.formatting {
432432
case SyntaxKind.ConstructorType:
433433
case SyntaxKind.ConstructSignature:
434434
return getList((node as SignatureDeclaration).typeParameters) || getList((node as SignatureDeclaration).parameters);
435+
case SyntaxKind.GetAccessor:
436+
return getList((node as GetAccessorDeclaration).parameters);
435437
case SyntaxKind.ClassDeclaration:
436438
case SyntaxKind.ClassExpression:
437439
case SyntaxKind.InterfaceDeclaration:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/// <reference path='fourslash.ts' />
2+
3+
// @noUnusedLocals: true
4+
// @noUnusedParameters: true
5+
6+
////let foo = {
7+
//// get x(/**/param) {}
8+
////}
9+
10+
verify.codeFix({
11+
description: "Remove unused declaration for: 'param'",
12+
index: 0,
13+
newFileContent:
14+
`let foo = {
15+
get x() {}
16+
}`
17+
})

0 commit comments

Comments
 (0)