Skip to content

noUnusedLocals incorrectly reports using resources as unused unless explicitly usedΒ #61890

Closed as duplicate of#55538
@dj-foxxy

Description

@dj-foxxy

πŸ”Ž Search Terms

noUnusedLocals
using

πŸ•— Version & Regression Information

Present on all releases supporting using

⏯ Playground Link

https://www.typescriptlang.org/play/?noUnusedLocals=true&target=99&ts=5.9.0-dev.20250618#code/N4KABBYK4M4JYDsDmYBmB7dYC8ZhgG0BlATwFsAjdAGwDoATOGAB3RgFMBdACgEo8AvmAEBuEAKA

πŸ’» Code

{
    using foo = { [Symbol.dispose]() {} };
}

πŸ™ Actual behavior

foo is flagged as unused by noUnusedLocals

πŸ™‚ Expected behavior

foo is not flagged by noUnusedLocals because it's implicitly used at the end of the scope when its [Symbol.dispose] property is called.

Additional information about the issue

Not explicitly referencing resources is common (e.g., mutexs) so this feels like a bug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions