Skip to content

This type parsing error and incorrect type inference #9744

@stephanedr

Description

@stephanedr

TypeScript Version: 2.0.0 (I suppose beta, though tsc -v just reports 2.0.0)

Code

function test(e: HTMLElement): void {
    e.onclick = (this: HTMLElement, event) => { }; // error TS1005: ')' expected.
                                                   // error TS1005: ';' expected.
                                                   // error TS1128: Declaration or statement expected.

    e.onclick = function(this: HTMLElement, event) { }; // error TS7006: Parameter 'event' implicitly has an 'any' type
}

Expected behavior:
1st: no parsing error.
2nd: event: MouseEvent inference, as for e.onclick = function(event) { };

Actual behavior:

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptDomain: Error MessagesThe issue relates to error messagingFixedA PR has been merged for this issueHelp WantedYou can do this

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions