google / google/closure-compiler

Side-effect of (0, obj.method)() is warned as no side-effect

Open
#1,868 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
7.7k
Forks
1.2k
Avg merge
2d 12h
Merged PRs (30d)
6

Description

Babel produces code that utilizes `(0, obj.method)()` in order to make a function call without the context being `obj` since `obj` is just a placeholder object for the methods that were imported.

When running code through Closure Compiler, it produces a warning:

```
JSC_USELESS_CODE: Suspicious code. This code lacks side-effects. Is there a bug? at line 165
dateStart = (0, _utilities.dateNow)();
```

That code does have the side-effect of calling `dateNow` without the context of `_utilities`.

The original code (before babel) stems from:

``` js
import { dateNow } from './utilities';
...
dateStart = dateNow();
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.