Skip to content

2.1 compile error: "Unexpected token ," for ternary operator. #12413

Closed
@unional

Description

@unional
function (m: string) {
    [1, 2, 3].map(i => {
        return true? { [m]: i } : false
    })
}

produces:

function (m) {
    [1, 2, 3].map(function (i) {
        return true ? _a = {}, _a[m] = i, _a : false;   // <-- unexpected token ,
        var _a;
    });
}

instead of:

function (m) {
    [1, 2, 3].map(function (i) {
        return true ? (_a = {}, _a[m] = i, _a) : false;
        var _a;
    });
}

Tested 2.0.10 is working correctly.

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