Skip to content

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

Closed

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.

Activity

  1. vladima commented on Nov 21, 2016

    @vladima
    Contributor

    Homa Wong (@unional) looks like this issue is identical to #12412. Closing the other one since this one seems to have better title and description

  2. unional commented on Nov 21, 2016

    @unional
    ContributorAuthor

    Just closed. Don't know why it is created twice.

  3. added this to the milestone on Nov 21, 2016
  4. mhegazy commented on Nov 21, 2016

    @mhegazy
    Contributor

    Vladimir Matveev (@vladima) can you take a look.

  5. locked and limited conversation to collaborators on Jun 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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