From 3f4412b173670eb45e592b5a8c0e4fa9c0ba026d Mon Sep 17 00:00:00 2001 From: Andy Date: Fri, 13 Jul 2018 10:30:22 -0700 Subject: [PATCH] getContainingList: Handle TypeAliasDeclaration (#25614) * getContainingList: Handle TypeAliasDeclaration * Handle ClassExpression and InterfaceDeclaration --- src/services/formatting/smartIndenter.ts | 5 ++++- .../fourslash/codeFixUnusedIdentifier_all_delete.ts | 10 +++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/services/formatting/smartIndenter.ts b/src/services/formatting/smartIndenter.ts index b024d1f94d0..c578c38cbc1 100644 --- a/src/services/formatting/smartIndenter.ts +++ b/src/services/formatting/smartIndenter.ts @@ -351,7 +351,10 @@ namespace ts.formatting { getListIfStartEndIsInListRange((node.parent).parameters, start, end); } case SyntaxKind.ClassDeclaration: - return getListIfStartEndIsInListRange((node.parent).typeParameters, node.getStart(sourceFile), end); + case SyntaxKind.ClassExpression: + case SyntaxKind.InterfaceDeclaration: + case SyntaxKind.TypeAliasDeclaration: + return getListIfStartEndIsInListRange((node.parent).typeParameters, node.getStart(sourceFile), end); case SyntaxKind.NewExpression: case SyntaxKind.CallExpression: { const start = node.getStart(sourceFile); diff --git a/tests/cases/fourslash/codeFixUnusedIdentifier_all_delete.ts b/tests/cases/fourslash/codeFixUnusedIdentifier_all_delete.ts index 5800fbcb129..4b485fd403e 100644 --- a/tests/cases/fourslash/codeFixUnusedIdentifier_all_delete.ts +++ b/tests/cases/fourslash/codeFixUnusedIdentifier_all_delete.ts @@ -37,6 +37,10 @@ ////for (let i = 0, j = 0; ;) {} ////for (const x of []) {} ////for (const y in {}) {} +//// +////export type First = T; +////export interface ISecond { u: U; } +////export const cls = class { u: U; }; verify.codeFixAll({ fixId: "unusedIdentifier_delete", @@ -70,5 +74,9 @@ takesCb((x, y) => { y; }); } for (; ;) {} for (const {} of []) {} -for (const {} in {}) {}`, +for (const {} in {}) {} + +export type First = T; +export interface ISecond { u: U; } +export const cls = class { u: U; };`, });