Skip to content

Type resolution error in vitest #968

@wojtekmaj

Description

@wojtekmaj

When evaluating tsgo (7.0.0-dev.20250528.1), I've noticed an error not visible in TypeScript (5.8.3):

vitest.config.ts:9:18 - error TS7006: Parameter 'id' implicitly has an 'any' type.

9       async load(id) {

I dug deeper and found that the defineConfig function from vitest/config has any instead of the expected types.

In vitest/dist/config.d.ts, we find:

import { UserConfig as UserConfig$1, ConfigEnv } from 'vite';
export { ConfigEnv, Plugin, UserConfig as ViteUserConfig, mergeConfig } from 'vite';

The first line returns errors for both imports:

Module '"node_modules/vite/index"' has no exported member '<IMPORT NAME HERE>'.

ctrl-clicking vite import path, I ended up in node_modules/vite/index.d.cts - something that I didn't expect, and what seems to be the clue of the original error.

https://github.com/vitejs/vite/blob/7052c8f6fc253f0a88ff04a4c18c108f3bfdaa78/packages/vite/index.d.cts#L1-L6

ctrl-clicking vite import path in TypeScript 5.8.3, I end up with a different resolved path: node_modules/vite/dist/node/index, while the types appear to be resolved to node_modules/vitest/dist/chunks/vite.Cu7NWuBa.d.ts (which includes declare module 'vite' { … bit).

Vite's imports are configured like so:

https://github.com/vitejs/vite/blob/7b588563636a6f735a6e25832f33fc08572b25d9/packages/vite/package.json#L19-L33

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions