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

[unbound-method] Support super.foo in constructor #1866

Closed
markfields opened this issue Apr 8, 2020 · 1 comment · Fixed by #3010
Closed

[unbound-method] Support super.foo in constructor #1866

markfields opened this issue Apr 8, 2020 · 1 comment · Fixed by #3010
Labels
bug Something isn't working has pr there is a PR raised to close this package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@markfields
Copy link

Repro

{
  "rules": {
    "@typescript-eslint/unbound-method": [
            "error",
            {
                "ignoreStatic": true
            }
        ]
  }
}
class BaseClass {
    x: number = 42;
    logThis() { console.log(`x is ${this?.x}`); }
}

class OtherClass extends BaseClass {
    superLogThis: any;
    constructor() {
        super();
        this.superLogThis = super.logThis;  // X - Incorrect eslint error
    }
}

const oc = new OtherClass();
oc.superLogThis();  // Works despite eslint error in constructor

Expected Result
No unbound-method error. In the test case above, oc.superLogThis() correctly prints x is 42.

Actual Result
unbound-method error about super.logThis in OtherClass's constructor.

Additional Info

Versions

package version
@typescript-eslint/eslint-plugin 2.17.0
@typescript-eslint/parser 2.17.0
TypeScript 3.7.5
ESLint 6.8.0
node 10.19.0
npm 6.13.4
@markfields markfields added package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for maintainers to take a look labels Apr 8, 2020
@bradzacher bradzacher added enhancement: plugin rule option New rule option for an existing eslint-plugin rule and removed triage Waiting for maintainers to take a look labels Apr 8, 2020
@bradzacher
Copy link
Member

This seems like something that's doable. Happy to accept a PR!

@bradzacher bradzacher added the has pr there is a PR raised to close this label May 17, 2020
@armano2 armano2 added bug Something isn't working and removed enhancement: plugin rule option New rule option for an existing eslint-plugin rule labels Feb 7, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 31, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working has pr there is a PR raised to close this package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
3 participants