Skip to content

[unbound-method] this annotation should fix error #854

@ThomasdenH

Description

@ThomasdenH

Repro

{
  "@typescript-eslint/unbound-method": [
    "error",
    {
      "ignoreStatic": true
    }
  ]
}
const obj = {
  func(this: void): void {
    console.log('a');
  }
};

function acceptsFunc(a: () => void) {
  a();
}

acceptsFunc(obj.func);

Expected Result
Since the method explicitely doesn't use this in the function, the rule should not warn. (See also the relevant section in the Handbook)

Actual Result

Additional Info

error    Avoid referencing unbound methods which may cause unintentional scoping of `this`  @typescript-eslint/unbound-method

Versions

package version
@typescript-eslint/eslint-plugin 2.0.0
@typescript-eslint/parser 2.0.0
TypeScript 3.5.3
ESLint 6.1.0
node 11.15.0
npm 6.7.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy