Skip to content

'onclick' type of 'this' is wrong #564

Open
@ghost

Description

document.body.onclick = function() {
    console.log(this.innerHTML.length);
}

The code works in a browser and worked in typescript@3.0. But in typescript@3.1.0-dev.20180804 it is a compile error:

src/a.ts:3:22 - error TS2339: Property 'innerHTML' does not exist on type 'GlobalEventHandlers'.

3     console.log(this.innerHTML.length);

The value of this should be HTMLElement like it was before, not GlobalEventHandlers.
Detected in fabric and tingle.js on DefinitelyTyped.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions