google / google/closure-compiler
Unable to use @define with window property
- Dominant language
- JavaScript
- Stars
- 7.7k
- Forks
- 1.2k
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 6
Description
Given this `main.js` script:
```js
/**
* @define {boolean} Enable debug mode. Default is `true`.
*/
window.DEBUG = true;
if (window.DEBUG) {
alert('failure');
} else {
alert('success');
}
```
I would expect to be able to run the compiler with `window.DEBUG=false` and have the resulting script `alert('success')`.
Instead, I get `WARNING - unknown @define variable window.DEBUG`. See below for the full output:
```
$ java -jar closure-compiler-v20161201.jar -D "window.DEBUG=false" --js main.js
WARNING - unknown @define variable window.DEBUG
0 error(s), 1 warning(s)
window.DEBUG=!0;window.DEBUG?alert("failure"):alert("success");
```
Contributor guide
Assessment
This issue has not been assessed yet.