Skip to content

can’t use 'this' in object literals with --noImplicitThis #10835

Closed
@msklvsk

Description

@msklvsk

TypeScript Version: 2.1.0-dev.20160910

Code

let literal = {
  a: 1,
  getA() {
    return this.a
   // error: 'this' implicitly has type 'any' because it does not have a type annotation
  },
}

Expected behavior: there is a way to use this in an object literal while noImplicitThis enabled

Actual behavior: an error is shown, even with getA: function(this: this) notation

Metadata

Metadata

Assignees

No one assigned

    Labels

    QuestionAn issue which isn't directly actionable in code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions