wxt-dev / wxt-dev/wxt

Node types are pulled accidentally by importing vite types

Open
#1,459 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
10.5k
Forks
564
PR merge metrics
No merged PRs in 30d

Description

Describe the bug

See the same issue in different package https://github.com/Anber/wyw-in-js/issues/33

I was investigating why node types are included in my project and came to cause being .wxt/types/imports.d.ts file, which imports for example:
const ContentScriptContext: typeof import('wxt/client')['ContentScriptContext']

And that file uses:

import { ContentScriptDefinition } from '../../types'

Which in turn imports:
import type * as vite from 'vite';

If we look at vite, it uses <reference types="node" /> which means any file importing it also gets the same types.

Image

The fix would be split vite types from client ones, so two are not mixed.

Reproduction

n/a

Steps to reproduce

Try using const timeout: number = setTimeout(() => {})

System Info
"wxt": "^0.19.27"
Used Package Manager

pnpm

Validations

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with .wxt/types/imports.d.ts, follow its import of ../../types, and inspect the ContentScriptDefinition declaration and its import type * as vite from 'vite'. Separate the Vite-related types from client types so consuming the generated imports does not pull in Node types; verify that the timeout example no longer receives Node-specific typing.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript, vite
Domain
build-system, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.