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

no-unused-vars doesn't count calling a method from a closure in right-hand side #1318

Open
dgreensp opened this issue Sep 3, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@dgreensp
Copy link

dgreensp commented Sep 3, 2024

Lint Name

no-unused-vars

Code Snippet

const foo = new MyClass(() => {
  foo.hello();
});

Expected Result

No lint errors

Actual Result

Error on const foo

Additional Info

This situation arises when new MyClass has a side-effect, for example attaching event handlers. For the sake of illustration:

class MyClass {
  constructor(run: () => void) {
    setTimeout(run, 1000);
  }
  hello() {
    console.log("hello");
  }
}

In searching for this issue, I only found #667.

Version

deno 1.46.2 (stable, release, aarch64-apple-darwin)
v8 12.9.202.5-rusty
typescript 5.5.2
@dgreensp dgreensp added the bug Something isn't working label Sep 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant