google/closure-compiler

Unknown type 'BeforeUnloadEvent'

Aperta

#3987 aperta il 16 ago 2022

 (3 commenti) (0 reazioni) (0 assegnatari)Java (1197 fork)batch import
help wanted

Metriche repository

Star
 (7176 stelle)
Metriche merge PR
 (Merge medio 3g 4h) (1 PR mergiata in 30 g)

Descrizione

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?

Guida contributor