#The inferred type of 'default' cannot be named without a reference to 'astro/node_modules/vite'.

6 messages · Page 1 of 1 (latest)

glossy arch
#

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?

naive juniper
#

CC @bronze steeple maybe you've encountered something like this before?

bronze steeple
#

I was going to setup a react test for Markdoc renderer, but we ended up dropping the react components out of it before actually getting to setup any tests for it.

#

I also use the Astro Container API for my astro tests 🤔

shadow knoll
#

This ts error is the worst...