Open BrunnerLivio opened 2 months ago
I am aware this is not directly related to this library but rather to Vite's typing of ImportMetaEnv
(see below). Feel free to close if you think this should not be discussed as part of this project. However I think it would be worth adding a documentation entry in this project's README if we'd find a solution for this - hence why I created an issue here.
node_modules/vite/types/importMeta.d.ts
interface ImportMetaEnv {
[key: string]: any
BASE_URL: string
MODE: string
DEV: boolean
PROD: boolean
SSR: boolean
}
Vite seems to add [key: string]: any
as a default. I wonder whether there is a way we could overwrite that. Since we have to use an interface to augment ImportMetaEnv
and to make the module augmentation work I am not too sure how though.
I've already tried the following without avail:
env.d.ts
type ImportMetaEnvAugmented =
import('@julr/vite-plugin-validate-env').ImportMetaEnvAugmented<
typeof import('./src/env').default
>
interface ImportMetaEnv extends ImportMetaEnvAugmented {
[key: string]: never
}
I am looking for a way to ONLY allow using env variables that are defined in my
env.ts
schema.As an example:
env.ts
In the application code, the following should occur (desired behavior)
src/app.ts