Skip to content

No warning when you use 'this' inside a function #2770

Closed
@wizofaus

Description

@wizofaus

If my class consists of

class X {
  foo() {
  }
  bar() {
     setTimeout(function() {
        this.foo();
     }, 10)
  }
}

I really should get some sort of warning that "this" doesn't mean what I think it means (or that I should use lambda syntax). This has bitten me repeatedly as I've been converting js code into ts code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    By DesignDeprecated - use "Working as Intended" or "Design Limitation" instead

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions