diff --git a/src/services/codefixes/fixUnusedIdentifier.ts b/src/services/codefixes/fixUnusedIdentifier.ts index f11c6bce72f..df44b8b2e5a 100644 --- a/src/services/codefixes/fixUnusedIdentifier.ts +++ b/src/services/codefixes/fixUnusedIdentifier.ts @@ -316,6 +316,10 @@ namespace ts.codefix { // Setter must have a parameter return false; + case SyntaxKind.GetAccessor: + // Getter cannot have parameters + return true; + default: return Debug.failBadSyntaxKind(parent); } diff --git a/src/services/formatting/smartIndenter.ts b/src/services/formatting/smartIndenter.ts index de223963832..da74c36afcb 100644 --- a/src/services/formatting/smartIndenter.ts +++ b/src/services/formatting/smartIndenter.ts @@ -432,6 +432,8 @@ namespace ts.formatting { case SyntaxKind.ConstructorType: case SyntaxKind.ConstructSignature: return getList((node as SignatureDeclaration).typeParameters) || getList((node as SignatureDeclaration).parameters); + case SyntaxKind.GetAccessor: + return getList((node as GetAccessorDeclaration).parameters); case SyntaxKind.ClassDeclaration: case SyntaxKind.ClassExpression: case SyntaxKind.InterfaceDeclaration: diff --git a/tests/cases/fourslash/codeFixUnusedIdentifier_parameterInGetAccessor.ts b/tests/cases/fourslash/codeFixUnusedIdentifier_parameterInGetAccessor.ts new file mode 100644 index 00000000000..e70afb997db --- /dev/null +++ b/tests/cases/fourslash/codeFixUnusedIdentifier_parameterInGetAccessor.ts @@ -0,0 +1,17 @@ +/// + +// @noUnusedLocals: true +// @noUnusedParameters: true + +////let foo = { +//// get x(/**/param) {} +////} + +verify.codeFix({ + description: "Remove unused declaration for: 'param'", + index: 0, + newFileContent: +`let foo = { + get x() {} +}` +})