Can a dedicated DTS for Service Workers be defined that defines self using ServiceWorkerGlobalScope instead of WorkerGlobalScope (e.g. "serviceworker" DTS that might even share some types with "webworker" DTS)? Alternatively some support for doing a type guard (e.g. if (self instanceof ServiceWorkerGlobalScope)) could be helpful if the types were define to narrow accordingly.
Type Checking Web Workers | Types and Type Declarations | Manual | Deno outlines option to type check web workers but I do not see clear instructions for doing this for service workers. The best I've been able to find so far by explicitly casting
self
:Can a dedicated DTS for Service Workers be defined that defines
self
usingServiceWorkerGlobalScope
instead ofWorkerGlobalScope
(e.g. "serviceworker" DTS that might even share some types with "webworker" DTS)? Alternatively some support for doing a type guard (e.g.if (self instanceof ServiceWorkerGlobalScope)
) could be helpful if the types were define to narrow accordingly.