Tslint: no-unbound-method warns when deleting property

Created on 29 Mar 2018  Â·  4Comments  Â·  Source: palantir/tslint

Bug Report

  • __TSLint version__: 5.9.1
  • __TypeScript version__: 2.4.2
  • __Running TSLint via__: CLI

TypeScript code being linted

const a = {
  getText() {
    return 'text';
  }
};

delete a.getText;

with tslint.json configuration:

{
  "rules": {
    "no-unbound-method": true
  }
}

Actual behavior

Error Avoid referencing unbound methods which may cause unintentional scoping of 'this'.

Expected behavior

No error. I am deleting a property. There is no risk on deleting unbound method compared to other kind of properties.

Easy Requires Type Checker Accepting PRs Bug

All 4 comments

Hi, I think I could fix this issue by adding allow-delete parameter similar to what I have done previously for typeof operator. What do you think about such solution?

@piotrgajow that sounds great, yes please! 😄

Ok, I have made PR for this change.

Fxed by #4548! ✨

Was this page helpful?
0 / 5 - 0 ratings