You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Unused variables are not shown as errors in VS Code when using noUnusedLocals #55099
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:
🙂 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:
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.
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.
This behavior is controlled by the "Report Style Checks as Warnings" setting in VS Code, which you can turn off
Oh wow, thanks so much Ryan Cavanaugh (@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!
Activity
MartinJohns commentedon Jul 21, 2023
Sounds like a duplicate of #13408.
cpojer commentedon Jul 21, 2023
Ah, thanks. 6 years old 🫠
fatcerberus commentedon Jul 21, 2023
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
tsctreats 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 commentedon Jul 21, 2023
This behavior is controlled by the "Report Style Checks as Warnings" setting in VS Code, which you can turn off
fatcerberus commentedon Jul 21, 2023
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 commentedon Jul 21, 2023
#37616 was the PR that originated this FWIW
cpojer commentedon Jul 22, 2023
Oh wow, thanks so much Ryan Cavanaugh (@RyanCavanaugh). I scanned all the options but didn't realize that
noUnusedLocalsis 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!