Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I delete all unused imports in the active file with one command in VS Code (typescript)?

Previously, I used to be able to do CMD+SHIFT+p > Organize imports and this would both sort and delete unused imports. This functionality seems to have broken.

How can I delete unused imports quickly with one command?

Current workaround is: click on unused import, CMD+. > Delete unused imports.

enter image description here

Languages for which this is applicable (typescript, typescriptreact, javascript, javascriptreact).

I have confirmed VS code is using a recent version of typescript unlike people in this post enter image description here

like image 684
david_adler Avatar asked Oct 16 '25 21:10

david_adler


1 Answers

It turns out that Organize Imports does actually work as expected but it was conflicting with the Deno plugin.

I found this out by using the amazingly useful Extension Bisect feature which is built into Visual Studio Code. Extension Bisect disables half your extensions and asks you to check if the issue persists. This process is repeated until only a single extension is left. I strongly recommend trying it out via CMD+SHIFT+P > Start Extension Bisect

Turns out my issue is a duplicate of this GitHub issue.

like image 127
david_adler Avatar answered Oct 18 '25 10:10

david_adler



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!