Skip to content

This typing not honored #12812

@wimoy

Description

@wimoy

TypeScript Version: 2.0.3

Code

interface UIElement {
    addClickListener(onclick: (this: UIElement, e: Event) => void): void;
    prop: number;
}

let uiElement: UIElement;
uiElement.addClickListener(() => {
    var k = this.prop;
});

Expected behavior:

No error

Actual behavior:
tsc.exe --noImplicitThis blah.ts
blah.ts(8,10): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation.

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