kit
kit copied to clipboard
Generate types for `src/service-worker.js`
Describe the problem
At present you need to add types for the service worker to clue TypeScript in about the WebWorker scope and set self to ServiceWorkerGlobalScope.
Describe the proposed solution
SvelteKit should generate types into the types folder.
Alternatives considered
Writing my own types. It typically involves adding triple-slash directives in my src/service-worker.js.
/// <reference no-default-lib="true"/>
/// <reference lib="esnext" />
/// <reference lib="webworker" />
self.addEventListener('install', (event) => {
/** @type {ExtendableEvent} */ (event).SpecialServiceWorkerStuff
And creating src/service-worker.d.ts
declare const self: ServiceWorkerGlobalScope;
Importance
nice to have
Additional Information
TS Context: https://github.com/microsoft/TypeScript/issues/14877.