google/closure-compiler

Unknown type 'BeforeUnloadEvent'

开放

#3,987 创建于 2022年8月16日

 (3 条评论) (0 个反应) (0 位负责人)Java (1,197 个派生)batch import
help wanted

仓库指标

星标
 (7,176 个星标)
PR 合并指标
 (PR 指标待抓取)

描述

test.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:

onbeforeunload = function(e) {
    console.log(e);
    e.preventDefault();
    return "";
};

returns BeforeUnloadEvent in the console. Why does GCC not support it?

贡献者指南