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

TypeScript: Vite relies on "dom" lib #14513

Closed
7 tasks done
sheremet-va opened this issue Oct 2, 2023 · 2 comments
Closed
7 tasks done

TypeScript: Vite relies on "dom" lib #14513

sheremet-va opened this issue Oct 2, 2023 · 2 comments

Comments

@sheremet-va
Copy link
Member

Describe the bug

When using vite with TypeScript that doesn't reference dom lib, type checking gives an error:

node_modules/.pnpm/vite@4.4.9_@types+node@20.8.0/node_modules/vite/types/customEvent.d.ts:26:14 - error TS2304: Cannot find name 'WebSocket'.

26   webSocket: WebSocket
                ~~~~~~~~~

node_modules/.pnpm/vite@4.4.9_@types+node@20.8.0/node_modules/vite/types/importGlob.d.ts:36:11 - error TS2304: Cannot find name 'Worker'.

36   worker: Worker
             ~~~~~~

This happens because vite exports type GeneralImportGlobOptions from its vite entry:

import type { GeneralImportGlobOptions } from 'types/importGlob'

This is a problem because types/importGlob references a global Worker variable that doesn't exist in @types/node (which is an optional dependency of Vite). WebSocket has the same problem. Ideally, we should have a separate shared file from which these options can be imported. Or they can also just be inlined in the vite entrypoint.

Reproduction

https://stackblitz.com/edit/node-rygrfb?file=tsconfig.json,index.ts,package.json

Steps to reproduce

pnpm run test

System Info

Stackblitz

Used Package Manager

npm

Logs

No response

Validations

@bluwy
Copy link
Member

bluwy commented Oct 3, 2023

We have another report for this at #9813. Closing in favour of it.

@bluwy bluwy closed this as not planned Won't fix, can't repro, duplicate, stale Oct 3, 2023
@sheremet-va
Copy link
Member Author

We have another report for this at #9813. Closing in favour of it.

Thank you! GitHub search is quite bad 🙏🏻

@github-actions github-actions bot locked and limited conversation to collaborators Oct 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants