Skip to content

"Delete all unused declarations" on TS imports removes code in files #30260

@oguimbal

Description

@oguimbal
  • VSCode Version: 1.31.1
  • OS Version: Windows 10 (not relevant)

Steps to Reproduce:

I feel that something is terribly wrong with the current behaviour of "Delete all unused declarations" codefix.

It is suggested to remove an unused import. In this context, its implicit meaning is (for me) something like "Delete all unused imports ".

But the actual behaviour can be quite dangerous, as it can remove actual code in the file body (which is definitely not something I would expect when refactoring dependencies):

anim

We experienced this in my team recently (and deleted parts of code that should not have been deleted), and I dont understand how this can be the default behaviour.

NB: I'm not suggesting to fix the "Delete all unused declaration" codefix, rather to use another codefix when refactoring the depenency context... so I was not sure if this issue has to be posted on the Typescript repository, or here.

Does this issue occur when all extensions are disabled?: Yes

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptDomain: LS: Quick FixesEditor-provided fixes, often called code actions.Help WantedYou can do this

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions