mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-04-12 23:36:28 -05:00
Fixed "Delete all unused declarations" to delete self-referential functions (#60888)
This commit is contained in:
committed by
GitHub
parent
0745e6a0e0
commit
8da951cbb6
@@ -200,6 +200,9 @@ registerCodeFix({
|
||||
else if (canDeleteEntireVariableStatement(sourceFile, token)) {
|
||||
deleteEntireVariableStatement(changes, sourceFile, token.parent as VariableDeclarationList);
|
||||
}
|
||||
else if (isIdentifier(token) && isFunctionDeclaration(token.parent)) {
|
||||
deleteFunctionLikeDeclaration(changes, sourceFile, token.parent as FunctionLikeDeclaration);
|
||||
}
|
||||
else {
|
||||
tryDeleteDeclaration(sourceFile, token, changes, checker, sourceFiles, program, cancellationToken, /*isFixAll*/ true);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
//// function fibonacci(n: number): number {
|
||||
//// if (n <= 1) {
|
||||
//// return n;
|
||||
//// }
|
||||
//// return fibonacci(n - 1) + fibonacci(n - 2);
|
||||
//// }
|
||||
////
|
||||
//// function other() {}
|
||||
////
|
||||
//// export {};
|
||||
|
||||
verify.codeFixAll({
|
||||
fixId: "unusedIdentifier_delete",
|
||||
fixAllDescription: ts.Diagnostics.Delete_all_unused_declarations.message,
|
||||
newFileContent: "\n\nexport {};",
|
||||
});
|
||||
Reference in New Issue
Block a user