Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

static-this - Improperly flags returned anonymous class #4579

Closed
onehorsetown opened this issue Mar 14, 2019 · 1 comment
Closed

static-this - Improperly flags returned anonymous class #4579

onehorsetown opened this issue Mar 14, 2019 · 1 comment

Comments

@onehorsetown
Copy link

onehorsetown commented Mar 14, 2019

Bug Report

  • 5.14:
  • 3..3.3333:
  • CLI

TypeScript code being linted

interface Bar {}

class Foo {
  public static higherOrderComponent(): any {
    return class implements Bar {
      public constructor() {
        console.log(this);   // "this" is valid here but tslint is complaining
      }
    };
  }
}

with tslint.json configuration:

{
  "defaultSeverity": "error",
  "extends": [
    "tslint:all"
  ],
  "rules": {
    "static-this": true
  }
}

Actual behavior

This improperly flags this in an anonymous class returned by a static function, something that is typically used to construct higher-order components.

Expected behavior

this used in a class scoped inside a static function is valid.

@mbelsky
Copy link
Contributor

mbelsky commented Mar 14, 2019

I'm already looking for a solution

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants