Seeing this error after updating from Astro 5.14 to 5.15. All our vitest.cofig.react.ts files seem to have the error:
The inferred type of 'default' cannot be named without a reference to 'astro/node_modules/vite'. This is likely not portable. A type annotation is necessary.ts(2742)
⚠ Error (TS2742) |
The inferred type of default cannot be named without a reference to astro/node_modules/vite . This is likely not portable. A type annotation is necessary.
(property) include: string[]
The config looks like this:
/// <reference types="vitest" />
import { getViteConfig } from "astro/config";
import { resolve } from "path";
export default getViteConfig({
test: {
environment: "jsdom",
setupFiles: ["./vitest.setup.ts"],
include: ["**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}"],
exclude: ["**/node_modules/**", "**/dist/**"],
// Mixed environments: React tests in jsdom, Astro container tests in node
environmentMatchGlobs: [["**/*.astro.test.{ts,js}", "node"]],
},
css: {
modules: {
// Deterministic names for tests → stable snapshots, no random hashes
// Safer than "[local]" (avoids collisions across files)
generateScopedName: "[name]__[local]",
// If you still want a touch of uniqueness:
// generateScopedName: "[name]__[local]__[hash:base64:2]",
},
},
});
How can we resolve this?