Every time I use workers in a TypeScript project, I feel like I'm fighting it. This is me trying to figure out the right way to do it. I have not yet succeeded.
To try to build:
npm i
npm run build
I think the answer is somewhere in Project References, but I haven't figured it out yet.
- In the root
tsconfig.json
, I have to tell it to ignore files indist
, else it drags them into the project. Surely I shouldn't have to do this? - It doesn't like that I'm trying to reference types in
dedicated-worker
frommain
. - It complains about
clients
insrc/service-worker/index.ts
, as it isn't usingServiceWorkerGlobalScope
as the global. - It complains about
event.request
insrc/service-worker/index.ts
, as it isn't using the service worker types foraddEventListener
.