Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

client types are incompatible with 'webworker' lib #3905

Closed
6 tasks done
lgrahl opened this issue Jun 22, 2021 · 2 comments · Fixed by #7877
Closed
6 tasks done

client types are incompatible with 'webworker' lib #3905

lgrahl opened this issue Jun 22, 2021 · 2 comments · Fixed by #7877

Comments

@lgrahl
Copy link

lgrahl commented Jun 22, 2021

Describe the bug

The vite/client types result in type errors when used in sources where lib was declared to be webworker. It runs fine in vite but throws errors when validating via tsc.

Reproduction

git clone https://github.com/lgrahl/vite-client-in-worker
cd vite-client-in-worker
npm install
npx tsc --noEmit -p src/app/tsconfig.json; npx tsc --noEmit -p src/worker/tsconfig.json

Analysis

The issue is that vite/client is referencing DOM (see vite/client.d.ts) which is a superset of what workers can do. However, AFAICT vite/client doesn't need that superset.

Related: microsoft/TypeScript#20595

Before submitting the issue, please make sure you do the following

@lgrahl
Copy link
Author

lgrahl commented Jun 22, 2021

For those interested in a workaround: If you don't need support for *?worker, *?worker&inline and *?sharedworker (which can be replaced easily by *?raw and *?url), copy vite/client.d.ts and reference that copy. Remove the declarations of the above mentioned module types.

@bluwy
Copy link
Member

bluwy commented Mar 12, 2022

IIUC /// <reference lib="dom" /> in vite/client is interfering with typechecking as it conflicts with webworker? I think that could be breaking. Perhaps we can expose another vite/worker instead? Feel free to send a PR if you have ideas to solve this, and we can discuss there onwards too.

@poyoho poyoho mentioned this issue Apr 23, 2022
9 tasks
@github-actions github-actions bot locked and limited conversation to collaborators May 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants