google / google/closure-compiler

Invalid "Suspicious re-assignment of "exports" variable" warning

Open
#3,003 1 comment 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

Compiling with ProcessCommonJSModules the example from https://github.com/google/closure-library/wiki/goog.module:-an-ES6-module-like-alternative-to-goog.provide:

```
goog.module('ns.Foo');
class Foo {}
exports = Foo;
```

yields (with today's tip):

```
Foo.js:5: WARNING - Suspicious re-assignment of "exports" variable. Did you actually intend to export something?
3| class Foo {}
4|
5| exports = Foo;
```

I'm pretty sure i'm not doing something wrong here. For now I'll suppress the warning.

Changing to `exports.Foo = Foo;` solves it, but changes the export pattern.

FYI @ChadKillingsworth

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.