Skip to content
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

Unused variables are not shown as errors in VS Code when using noUnusedLocals #55099

Closed
cpojer opened this issue Jul 21, 2023 · 7 comments
Closed
Labels
Question An issue which isn't directly actionable in code

Comments

@cpojer
Copy link

cpojer commented Jul 21, 2023

Bug Report

I'm using noUnusedLocals with TypeScript and VS Code. When a variable is unused, it will mark the variable with yellow squiggly lines (warning) instead of red ones (error) even though when running TypeScript with this option on the command line it shows the issue as an error. I expect that unused variables are reported as errors in VS Code.

🕗 Version & Regression Information

Latest Version (5.1.x).

⏯ Playground Link

Does not apply.

💻 Code

tsconfig.json contains:

"noUnusedLocals": true,

🙁 Actual behavior

Yellow squiggly lines:
CleanShot 2023-07-21 at 15 25 54@2x

🙂 Expected behavior

I would prefer them to be red, so that files in the tab view are also marked as red (error) for easier visual clarity, like when there are syntax or type errors:
CleanShot 2023-07-21 at 15 26 08@2x

@MartinJohns
Copy link
Contributor

Sounds like a duplicate of #13408.

@cpojer
Copy link
Author

cpojer commented Jul 21, 2023

Ah, thanks. 6 years old 🫠

@fatcerberus
Copy link

This feels like the opposite of #13408 (TS should be able to treat some things as warnings instead of errors), in that a thing that tsc treats as an error is weirdly being interpreted only as a warning in the IDE, when TS itself (currently) has no concept of a warning.

@RyanCavanaugh RyanCavanaugh added Needs More Info The issue still hasn't been fully clarified and removed Needs More Info The issue still hasn't been fully clarified labels Jul 21, 2023
@RyanCavanaugh
Copy link
Member

This behavior is controlled by the "Report Style Checks as Warnings" setting in VS Code, which you can turn off

image

@RyanCavanaugh RyanCavanaugh added the Question An issue which isn't directly actionable in code label Jul 21, 2023
@fatcerberus
Copy link

TIL that option exists. I'm a bit baffled by its existence though, IMO it never makes sense to have the IDE report something as a warning that will be an error at compile time, "style check" or no.

@RyanCavanaugh
Copy link
Member

RyanCavanaugh commented Jul 21, 2023

#37616 was the PR that originated this FWIW

@cpojer
Copy link
Author

cpojer commented Jul 22, 2023

This behavior is controlled by the "Report Style Checks as Warnings" setting in VS Code, which you can turn off

image

Oh wow, thanks so much @RyanCavanaugh. I scanned all the options but didn't realize that noUnusedLocals is considered a "style" check when it is actually a type error. I agree the alignment between TS and VS Code is a bit confusing here and should probably addressed, but that's a different discussion than what I created this issue for, so I'm going to close it. Thanks again!

@cpojer cpojer closed this as completed Jul 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Question An issue which isn't directly actionable in code
Projects
None yet
Development

No branches or pull requests

4 participants