closure-compiler icon indicating copy to clipboard operation
closure-compiler copied to clipboard

MediaQueryListEvent is an unknown type

Open GlennKnight opened this issue 3 years ago • 2 comments

I'm getting the following error when trying to use the MediaQueryListEvent type:

WARNING - [JSC_UNRECOGNIZED_TYPE_ERROR] Bad type annotation. Unknown type MediaQueryListEvent

Code:

    /**
     * Handle MediaQueryList change event
     * @param {MediaQueryListEvent} ev
     */
    handleChange(ev) {
        ...
    }

The code passes type checking in VSCode and 'Go to Definition' works.

I'm running "google-closure-compiler": "^20210601.0.0"

It looks like MediaQueryListEvent has been around for a while (https://developer.mozilla.org/en-US/docs/Web/API/MediaQueryListEvent) so maybe it's just a missing extern?

I've tried suppressing the warning for now by adding @suppress {checkTypes}, but that doesn't seem to work.

GlennKnight avatar Jun 20 '21 00:06 GlennKnight

I think that the MediaQueryListEvent should've been defined inside https://github.com/google/closure-compiler/blob/master/externs/browser/w3c_css.js, but I see that it isn't. Were you able to check that adding it to w3c_css.js fixes it?

rishipal avatar Jun 22 '21 03:06 rishipal

I think that the MediaQueryListEvent should've been defined inside https://github.com/google/closure-compiler/blob/master/externs/browser/w3c_css.js, but I see that it isn't. Were you able to check that adding it to w3c_css.js fixes it?

I'm using the npm package instead of building it myself so I haven't been able to try adding a fix. Instead, I created my own local externs file to remove the error

GlennKnight avatar Jun 23 '21 21:06 GlennKnight