-
Notifications
You must be signed in to change notification settings - Fork 29.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Highlight unused symbols #15710
Comments
If possible, in addition, a right-click option to clean up unused symbols would be useful :-) |
Thank you for your feature request! We have discussed this internally and have considered adding it soon. |
Webstorm has it and it is really really handy! Would love to have it in VSCode for TypeScript and JavaScript. |
Related API request #20219 |
#23805 Notes that we could also investigating graying out unreachable code |
Sorry if that's not the right place to ask this, but is this being implemented anytime soon (local unused variables)? It would be a huge improvement IMO. This is the only reason that makes me consider switching to WebStorm, though I really enjoy VS! |
Storm is generally awful at Typescript, but yes, I occasionally find myself opening Storm just to check for unused symbols. Would be great to have this. |
today one unused variables make me error, i hope vs can support it |
i'm reading through this issue for i want this too, please make it happen. |
I think i could get rid of Storm with this feature~ |
Would love this feature as well. A major hiccup in refactoring that forces me to switch to WebStorm to run these checks. I'd rather stay in VS Code the entire time. Please, please, make this happen. |
I am also using Webstorm just for this feature. Would make switching a breeze! Thanks for the work put into VSCode |
Two of our projects in JavaScript. I am interested in the feature. Thanks, |
+1 |
2 similar comments
👍 |
+1 |
If you guys could just use thumbs up emojis instead of flooding issues with |
Would like to add my support to this feature. To some developers, it is not particularly a personal preference, but a requirement coming from the enterprise Quality Gates, that may detect and reject code containing unused variables (my current scenario). |
I will surely get rid of WebStorm as soon as this gets implemented! |
@here to everyone who is using VS Code for TypeScript development.
It will highlight the variable or class member with green curly line (at least it looks like that with my color theme): Also in Problems panel you will see a warning: Read more about compiler options here |
+1 |
Hey to all, look what I've found a few days ago: This awesome extension not only allows to remove unused imports, but - following my feature request - now also highlights them: TypeScript / JavaScript Deporter. The visuals could use some improvements, but overall it it works like a charm in my projects! |
Depends on microsoft/TypeScript#22361 As already noted, you can already enable this using settings in your
|
There's now a |
Gated behind undocumented setting. Requires proper vscode API Part of #15710
Fixes #15710 Adds a new `DiagnosticTag` class that provide additional information about a diagnostic. Introduce `DiagnosticTag.Unnecessary` to mark when a diagnostic is for unused / unnecessary code The design comes from Rosyln's diagnostic object and allows us to modify how a diagnostic is rendered without changing its serverity. Hooks up JS and TS to use this new tag. This is controlled by the `javascript.showUnused.enabled` setting which is enabled by default - Introduce a new diagnostic severity for unused. However, using this approach, if a user sets `noUnusedLocals` in their `tsconfig.json`, the resulting diagnostic could only show the squiggly OR be grayed out. Using `customTags` allows us to support both graying out and showing the squiggly - Custom JS/TS implementation using decorators Not themable. We want a standard experience across languages.
Fixes #15710 Adds a new `DiagnosticTag` class that provide additional information about a diagnostic. Introduce `DiagnosticTag.Unnecessary` to mark when a diagnostic is for unused / unnecessary code The design comes from Rosyln's diagnostic object and allows us to modify how a diagnostic is rendered without changing its serverity. Hooks up JS and TS to use this new tag. This is controlled by the `javascript.showUnused.enabled` setting which is enabled by default - Introduce a new diagnostic severity for unused. However, using this approach, if a user sets `noUnusedLocals` in their `tsconfig.json`, the resulting diagnostic could only show the squiggly OR be grayed out. Using `customTags` allows us to support both graying out and showing the squiggly - Custom JS/TS implementation using decorators Not themable. We want a standard experience across languages.
* Add unused diagnostic subtype Fixes #15710 Adds a new `DiagnosticTag` class that provide additional information about a diagnostic. Introduce `DiagnosticTag.Unnecessary` to mark when a diagnostic is for unused / unnecessary code The design comes from Rosyln's diagnostic object and allows us to modify how a diagnostic is rendered without changing its serverity. Hooks up JS and TS to use this new tag. This is controlled by the `javascript.showUnused.enabled` setting which is enabled by default - Introduce a new diagnostic severity for unused. However, using this approach, if a user sets `noUnusedLocals` in their `tsconfig.json`, the resulting diagnostic could only show the squiggly OR be grayed out. Using `customTags` allows us to support both graying out and showing the squiggly - Custom JS/TS implementation using decorators Not themable. We want a standard experience across languages. * - Move to proposed - Use numeric enum
Is this works only for JavaScript and TypeScript? |
@Zx-EvM Just JS/TS, maybe you should open an issue with a language plugin that you think should support this too. But it would be a lot of work if that language doesn't support unused variables yet; for this issue TypeScript already supported detecting unused variables and all we had to do was send that info to the editor. |
I'd like to request an improvement to Typescript support: highlighting of unused symbols.
Refactoring and moving things around between files often leads to a lot of manual analysis, for example to find imports that are no longer in use.
This doesn't need to be a big, complex feature - I don't expect this to trawl through the entire codebase and figure out what is or isn't in use.
I'd be happy with just file-local highlighting - e.g. gray out variable and constant declarations if they aren't exported or used in any expression or statement anywhere in the file.
The text was updated successfully, but these errors were encountered: