4👍
✅
You can augment ImportMetaEnv
to add the type for any custom environment variables you’re using:
-
In
src/env.d.ts
(create if needed), add the following code:/// <reference types="vite/client" /> interface ImportMetaEnv { readonly VITE_API_URL: string }
-
If using VS Code, you might need to restart the TypeScript server (or the IDE itself) for the types to be reloaded.
Source:stackexchange.com