Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
unional opened this issue Nov 21, 2016 · 3 comments · Fixed by #12420
Closed

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

unional opened this issue Nov 21, 2016 · 3 comments · Fixed by #12420
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue

Comments

@unional
Copy link
Contributor

unional commented Nov 21, 2016

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.

@vladima
Copy link
Contributor

vladima commented Nov 21, 2016

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

@unional
Copy link
Contributor Author

unional commented Nov 21, 2016

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

@RyanCavanaugh RyanCavanaugh added the Bug A bug in TypeScript label Nov 21, 2016
@mhegazy mhegazy assigned rbuckton and vladima and unassigned rbuckton Nov 21, 2016
@mhegazy mhegazy added this to the TypeScript 2.1.3 milestone Nov 21, 2016
@mhegazy
Copy link
Contributor

mhegazy commented Nov 21, 2016

@vladima can you take a look.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants