Skip to content

(0,eval) produces TS2695 #12978

Closed
Closed

Description

TypeScript Version: 2.1.4

(0,eval)('var x = 10');

Expected behavior:
Compile fine.

Actual behavior:
error TS2695: Left side of comma operator is unused and has no side effects.

See also at TS Playground.

(0,eval) is a well-used convenience syntax for invoking eval with a global scope (as opposed to the scope of the caller).

One possible workaround is: (eval||null). But that's longer and most of all — hard to Google the reasoning behind. Whereas (0,eval) is easy to find a detailed explanation for.

Please make it not error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    FixedA PR has been merged for this issueHelp WantedYou can do thisSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions