Closed
Description
Describe the bug
when attempting to compile a vite.config.ts
file without dom types, and without skipLibCheck
in tsconfig.json
, the following errors occur:
❯ tsc
node_modules/esbuild/lib/main.d.ts:592:16 - error TS2503: Cannot find namespace 'WebAssembly'.
592 wasmModule?: WebAssembly.Module
~~~~~~~~~~~
node_modules/vite/dist/node/index.d.ts:1259:13 - error TS2304: Cannot find name 'Worker'.
1259 worker: Worker
~~~~~~
Found 2 errors in 2 files.
Errors Files
1 node_modules/esbuild/lib/main.d.ts:592
1 node_modules/vite/dist/node/index.d.ts:1259
i believe it's because these types are defined globally in lib.dom.d.ts
. but since the vite.config.ts
file is executed by nodejs, it's incorrect to include the dom types when compiling it.
is it possible to resolve this by importing the Worker
type from elsewhere?
- esbuild issue: Cannot find namespace 'WebAssembly' evanw/esbuild#2388
- typescript issue: a way to import from a module without including its globals microsoft/TypeScript#50424
Reproduction
System Info
❯ npx envinfo --system --npmPackages '{vite,@vitejs/*}' --binaries --browsers
ERR!: Failed to install package
error Command failed with exit code 1
Used Package Manager
npm
Logs
No response
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to vuejs/core instead.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.