Skip to content

client types are incompatible with 'webworker' lib #3905

@lgrahl

Description

@lgrahl

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions