Typing env variables on typescript

Typing env variables on typescript

As a backend developer, I’ve been working with typescript, on some projects we are required to use different types of environment files, the most common is using environment files, but there are some specific cases where we need to use other types because the tools that we use requires a yaml, JSON or other file formats, we already have a perfect tool like dotenv-yaml – npm or dotenv – npm. But something comes to my mind, what if we have a package that can support any env files 🤔…

So I made a try, and I created ts-env, we can manage different types of env files, currently supporting YAML, ‘TOML’, ‘JSON’ files

Typing

It also supports typing the process.env which helps a lot to know which variables we have on the env file.

So we can have a lint suggestion on the editor

Conclusion

I don’t know if this is a real problem, if it is not, at least was interesting doing int, so let me know what do you think