Type definitions for ServiceWorker(and optionally Workbox)
npm install types-serviceworker``sh`
yarn add -D https://github.com/shqld/types-serviceworker
`ts`
///
///
Or if you write Service Worker scripts with a dedicated tsconfig.json for that, you also can do by simply adding:
`json`
{
"compilerOptions": {
"types": [/ ...others /, "node_modules/types-serviceworker"],
/ ... /
}
/ ... /
}
NOTE: There are some caveats using types field. See this for detail.
> If types is specified, only packages listed will be included
types-serviceworker partially uses 2 files(src/webworkers.d.ts, src/workbox.d.ts`) respectively copied from
- TypeScript/lib/lib.webworker.d.ts
- DefinitelyTyped/types/workbox-sw/index.d.ts
and modifies them under the lincenses.