Vite · types

VITE0006Type custom Vite define globals

Flags untyped define in Vite define code before it leaks into runtime behavior.

Why it happens

Vite configuration runs in both dev and build pipelines. Narrow, explicit settings reduce surprises across SSR, workers, and local file access.

Fix

Remove untyped define, or move it to the Vite runtime/API that owns that behavior.

Example

Declare define constants

Before

export default defineConfig({
  define: {
    __FEATURE_FLAG__: JSON.stringify(true),
  },
})

After

declare const __FEATURE_FLAG__: boolean

export default defineConfig({
  define: {
    __FEATURE_FLAG__: JSON.stringify(true),
  },
})

Verify the fix

Run only this rule after editing so the report stays focused on the diagnostic you are closing:

pnpm vite-doctor . --framework vite --extends auto,vite/strict --rules vite/define/no-untyped-define
Copyright © 2026