You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You can use the plugin with the [built-in validator](https://github.com/poppinss/validator-lite) for simple use cases, or with libraries like Zod for more advanced schemas.
30
30
31
-
> [!TIP]
31
+
> [!TIP]
32
32
> I would recommend using a dedicated `env.ts` file to keep your Vite config clean and separate from your environment variable definitions. See the [Using a Dedicated `env.ts` Config File](#using-a-dedicated-envts-config-file) section for more details.
33
33
34
34
### Built-in Validator
@@ -160,27 +160,19 @@ type ImportMetaEnvAugmented = import('@julr/vite-plugin-validate-env').ImportMet
160
160
typeofimport('../env').default
161
161
>
162
162
163
+
interfaceViteTypeOptions {
164
+
// Avoid adding an index type to `ImportMetaDev` so
165
+
// there's an error when accessing unknown properties.
// Now import.meta.env is totally type-safe and based on your `env.ts` schema definition
165
172
// You can also add custom variables that are not defined in your schema
166
173
}
167
174
```
168
175
169
-
## Forbid unknown variables
170
-
171
-
Since we rely on module augmentation to type `import.meta.env`, using unknown variables won’t trigger errors because the `ImportMetaEnv` interface from Vite includes a `[key: string]: string` signature.
172
-
173
-
To enforce stricter typing and prevent the use of unknown variables, you can set up the following:
0 commit comments