Skip to content

Do not issue Left side of comma operator is unused and has no side effects error on (0, expr) this-removing pattern #48163

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
weswigham opened this issue Mar 7, 2022 · 5 comments
Labels
Bug A bug in TypeScript Domain: Error Messages The issue relates to error messaging Help Wanted You can do this
Milestone

Comments

@weswigham
Copy link
Member

Both our and babel's output emits (0, expr) in many places to unbind the this from the call that's about to be done. Ergo, the 0, expr pattern is not without side-effects, and is, in fact, a very highly used pattern that we probably shouldn't issue an error on. It's probably OK to special-case the literal-zero LHS as a signal to silence the error.

@weswigham weswigham added Bug A bug in TypeScript Domain: Error Messages The issue relates to error messaging labels Mar 7, 2022
@RyanCavanaugh
Copy link
Member

I would prefer 0 as the left operand and the parent expression is a call

@muuvmuuv
Copy link

Damn, any workaround for this? I am in a NX Workspace, and we are trying to compile a custom executor.

 >  NX   ⨯ Unable to compile TypeScript:

   apps/entergon/webpack.config.ts:9:19 - error TS2695: Left side of comma operator is unused and has no side effects.

   9 const _default = (0, _webpack.createConfig)("entergon", (config)=>{

@RyanCavanaugh RyanCavanaugh added this to the Backlog milestone Oct 14, 2022
@RyanCavanaugh RyanCavanaugh added the Help Wanted You can do this label Oct 14, 2022
@shicks
Copy link
Contributor

shicks commented Dec 21, 2022

This is a duplicate of #35866

@shicks
Copy link
Contributor

shicks commented Jan 25, 2023

This should be able to be closed now that #51989 is merged.

@RyanCavanaugh
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Domain: Error Messages The issue relates to error messaging Help Wanted You can do this
Projects
None yet
Development

No branches or pull requests

4 participants