feross / queue-microtask

fast, tiny `queueMicrotask` shim for modern engines

Home Page:https://feross.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Not compatible with strict mode

yunyu opened this issue · comments

This package doesn't work when used with a bundler that enforces strict mode – switching to typeof globalThis.queueMicrotask would fix it

I am confused by this issue. typeof queueMicrotask === 'function' is perfectly valid code in strict mode. Please post an minimal example that reproduces your error.

@feross Here's an example: https://stackoverflow.com/questions/31540765/variable-typeof-object-in-strict-mode

I don't currently have access to a browser environment that triggers this, but I saw this exception reported via Sentry in an older version of Safari. If queueMicrotask doesn't exist, then typeof queueMicrotask is invalid in strict mode.

The accepted answer on StackOverflow makes no sense. You can always do typeof queueMicrotask – even in strict mode. This is how JavaScript works. If an old version of Safari is triggering a warning, then it's buggy behavior in Safari.