google / google/closure-compiler

Unknown type 'BeforeUnloadEvent'

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

Description

`test.js`:
```js
/** @type {BeforeUnloadEvent} */
var a;
```

Compiled with `closure-compiler -O ADVANCED --js test.js --js_output_file test.min.js` version `v20220601`:
```
test.js:1:11: WARNING - [JSC_UNRECOGNIZED_TYPE_ERROR] Bad type annotation. Unknown type BeforeUnloadEvent
1| /** @type {BeforeUnloadEvent} */
^

0 error(s), 1 warning(s)
```

That's strange, since the following executed in the browser:
```js
onbeforeunload = function(e) {
console.log(e);
e.preventDefault();
return "";
};
```
returns `BeforeUnloadEvent` in the console. Why does GCC not support it?

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.