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
// Now import.meta.env is totally type-safe and based on your `env.ts` schema definition
264
264
// You can also add custom variables that are not defined in your schema
265
265
}
266
+
```
267
+
268
+
## Forbid unknown variables
269
+
270
+
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.
271
+
272
+
To enforce stricter typing and prevent the use of unknown variables, you can set up the following:
By using `env` instead of `import.meta.env` in your code, TypeScript will now throw an error if you try to access an unknown variable.
282
+
269
283
## Sponsors
270
284
271
285
If you like this project, [please consider supporting it by sponsoring it](https://github.com/sponsors/Julien-R44/). It will help a lot to maintain and improve it. Thanks a lot !
0 commit comments