google / google/closure-compiler
How to annotate a symbol outside the location of definition?
- Dominant language
- JavaScript
- Stars
- 7.7k
- Forks
- 1.2k
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 6
Description
When developing Closure minification support to Emscripten compiler, there is a need to annotate some symbols with e.g. `@suppress {undefinedVars}` or `@suppress {duplicate}`.
If I use an `--externs` file to specify an annotation, e.g. `--externs externs.js`, with
```js
/**
* @suppress {duplicate}
*/
var foo;
```
then not only does Closure take in the annotation, but it also then will no longer minify `foo`, because it is being specified in an externs file.
If I use a `--js` file before the main JS file to specify an annotation, e.g. `--js annotation.js --js main.js`, with
```js
/**
* @suppress {duplicate}
*/
var foo;
```
then Closure will want to add (in some scenarios, not quite sure when this occurs) a top level global dummy variable `var a;` in the beginning of the Closured output file, that takes up redundant space and bloats the final output.
What I'd like to do is specify a `--annotations annotations.js` file that would not prevent minification like externs does, but neither will cause dummy symbols being defined to the build output, like `--js` does. Is this possible somehow with current Closure?
Contributor guide
Assessment
This issue has not been assessed yet.