Skip to content

Object literal cast compiles to produce JS with syntax error #10129

Closed
@henrymercer

Description

@henrymercer

TypeScript Version: 2.0.0

Code

class A { }

window.onload = () => {
    (<A>{}).toString();
};

Expected behavior: The toString line should compile to: ({}).toString() or ({}.toString()) and hence there should not be a runtime syntax error

Actual behavior: The toString line compiles to {}.toString(), which is incorrect syntax and hence a syntax error is thrown at runtime.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptFixedA PR has been merged for this issue

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions