Skip to content

bug(prefer-timer-args): unbound method breaks this in classes #46

@shi-gg

Description

@shi-gg

e18e/prefer-timer-args breaks when a method inside a setInterval/setTimeout attempts to access the class instance using this..

It also collides with @typescript-eslint/unbound-method, which attempts to prevent bugs like this.

  11:21  error  A method that is not declared with `this: void` may cause unintentional scoping of `this` when separated from its object.
Consider using an arrow function or explicitly `.bind()`ing the method to avoid calling the method with an unintended `this` value.
If a function does not access `this`, it can be annotated with `this: void`  @typescript-eslint/unbound-method

Before: Working

Image

After: Broken

Image

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