Julien-R44 / vite-plugin-validate-env

✅ Vite plugin for validating your environment variables
MIT License
164 stars 6 forks source link

No intellisense / type on import env #8

Closed UnbreakableKid closed 1 year ago

UnbreakableKid commented 1 year ago

Hi, this might be a noob mistake but I'm trying and failing to make this work 100% and I might be missing a step.

I have created the standalone env.ts and the env.d.ts files in the src directory. When I'm using the import.meta.... I only get intellisense for the default env vars and not my new ones. When I do use them, I get an any type.

env.d.ts image

env.ts image

import in another .ts file image

Julien-R44 commented 1 year ago

Works perfectly on my side with Zod. Just tried it right now

Maybe just try restarting your TS server / reloading IDE ? Otherwise feel free to share a fresh repo that reproduce the issue but it seems to me it's an issue with your setup

Julien-R44 commented 1 year ago

Also make sure that your env.d.ts is located into your ./src directory and not at the top level Please also share your zod version

UnbreakableKid commented 1 year ago

I have apparently fixed it. I tried moving the env.d.ts to the root of the project and then it works. When it's at the src it does not.

outside of src image

inside of src image

zod version is 3.21.4