Skip to content

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

Closed

Description

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

Activity

  1. MartinJohns commented on Jul 21, 2023

    @MartinJohns
    Contributor

    Sounds like a duplicate of #13408.

  2. cpojer commented on Jul 21, 2023

    @cpojer
    Author

    Ah, thanks. 6 years old 🫠

  3. fatcerberus commented on Jul 21, 2023

    @fatcerberus

    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.

  4. RyanCavanaugh commented on Jul 21, 2023

    @RyanCavanaugh
    Member

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

    image

  5. fatcerberus commented on Jul 21, 2023

    @fatcerberus

    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.

  6. RyanCavanaugh commented on Jul 21, 2023

    @RyanCavanaugh
    Member

    #37616 was the PR that originated this FWIW

  7. cpojer commented on Jul 22, 2023

    @cpojer
    Author

    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 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!

  8. locked as resolved and limited conversation to collaborators on Oct 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    QuestionAn issue which isn't directly actionable in code

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions