Skip to content

cast and accessor with target es6 produces invalid code #14895

@MrAndersen1

Description

@MrAndersen1

TypeScript Version: 2.3.0-dev.20170328

Code

The following code produces wrong output, when run through tsc, only when target is es6, the "as"-cast exists and the accessor "[x]" exists.

(x) => ({ "1": "one", "2": "two" } as { [key: string]: string })[x];

Expected behavior:
Running "tsc -t es6" on the above code in a .ts file I expect to get a .js file containing:
(x) => ({ "1": "one", "2": "two" })[x];

Actual behavior:
(x) => { "1": "one", "2": "two" }[x];

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