Skip to content

Commit 3f4412b

Browse files
author
Andy
authored
getContainingList: Handle TypeAliasDeclaration (#25614)
* getContainingList: Handle TypeAliasDeclaration * Handle ClassExpression and InterfaceDeclaration
1 parent 27da9ea commit 3f4412b

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/services/formatting/smartIndenter.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,10 @@ namespace ts.formatting {
351351
getListIfStartEndIsInListRange((<SignatureDeclaration>node.parent).parameters, start, end);
352352
}
353353
case SyntaxKind.ClassDeclaration:
354-
return getListIfStartEndIsInListRange((<ClassDeclaration>node.parent).typeParameters, node.getStart(sourceFile), end);
354+
case SyntaxKind.ClassExpression:
355+
case SyntaxKind.InterfaceDeclaration:
356+
case SyntaxKind.TypeAliasDeclaration:
357+
return getListIfStartEndIsInListRange((<ClassDeclaration | ClassExpression | InterfaceDeclaration | TypeAliasDeclaration>node.parent).typeParameters, node.getStart(sourceFile), end);
355358
case SyntaxKind.NewExpression:
356359
case SyntaxKind.CallExpression: {
357360
const start = node.getStart(sourceFile);

tests/cases/fourslash/codeFixUnusedIdentifier_all_delete.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@
3737
////for (let i = 0, j = 0; ;) {}
3838
////for (const x of []) {}
3939
////for (const y in {}) {}
40+
////
41+
////export type First<T, U> = T;
42+
////export interface ISecond<T, U> { u: U; }
43+
////export const cls = class<T, U> { u: U; };
4044

4145
verify.codeFixAll({
4246
fixId: "unusedIdentifier_delete",
@@ -70,5 +74,9 @@ takesCb((x, y) => { y; });
7074
}
7175
for (; ;) {}
7276
for (const {} of []) {}
73-
for (const {} in {}) {}`,
77+
for (const {} in {}) {}
78+
79+
export type First<T> = T;
80+
export interface ISecond<U> { u: U; }
81+
export const cls = class<U> { u: U; };`,
7482
});

0 commit comments

Comments
 (0)