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-invalid-this] False positive when using this to declare an attribute #2324

Closed
flowstate247 opened this issue Jul 25, 2020 · 1 comment
Closed
Labels
bug Something isn't working duplicate This issue or pull request already exists good first issue Good for newcomers package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@flowstate247
Copy link

flowstate247 commented Jul 25, 2020

Repro

{
  "rules": {
    "@typescript-eslint/no-invalid-this": ["warn"]
  }
}
class Example1 {
  i = 0
  inc(): void { this.i++ }
  alias = this.inc // Warning here
}

class Example2 {
  i = 0
  constructor() { this.alias = this.inc	}
  inc(): void { this.i++ }
  alias: () => void
}

Expected Result
No warning shown

Actual Result
Show warning "Unexpected 'this'" in the Example1 class

Additional Info
Example1 and Example2 classes are both valid TypeScript and generate identical JavaScript code.

Versions

package version
@typescript-eslint/eslint-plugin 3.7.0
@typescript-eslint/parser 3.7.0
TypeScript 3.9.7
ESLint 7.5.0
node v14.1.0
npm 6.14.4
@flowstate247 flowstate247 added package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for maintainers to take a look labels Jul 25, 2020
@flowstate247 flowstate247 changed the title [no-invalid-this] False positive warning when using this to declare an attribute [no-invalid-this] False positive when using this to declare an attribute Jul 25, 2020
@bradzacher bradzacher added bug Something isn't working good first issue Good for newcomers and removed triage Waiting for maintainers to take a look labels Jul 25, 2020
@bradzacher bradzacher added the duplicate This issue or pull request already exists label Aug 7, 2020
@bradzacher
Copy link
Member

#491

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working duplicate This issue or pull request already exists good first issue Good for newcomers package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
Development

No branches or pull requests

2 participants