auto-type-env is a Node.js library that automatically generates TypeScript types for your environment variables.
You can install auto-type-env via npm:
npm install -g auto-type-env
# or
npx auto-type-env
Here's a quick example to get you started with auto-type-env:
auto-type-env -p .env -t ./src/environment.d.ts
# or
auto-type-env # will use default values
Imagine you have a .env like this:
ULTRA_SECRET_VARIABLE=value
ANOTHER_SECRET=value2
This library will generate something like:
export {};
declare global {
namespace NodeJS {
interface ProcessEnv {
ULTRA_SECRET_VARIABLE: string;
ANOTHER_SECRET: string;
}
}
}
Then you will have all the items available for you when you type process.env
Contributions are welcome! If you find a bug, have a feature request, or want to contribute in any other way, please open an issue or submit a pull request. We appreciate your feedback and involvement in making auto-type-env even better.
auto-type-env is MIT licensed, which means you can use it freely in your projects, both personal and commercial.
If you have any questions, suggestions, or feedback, you can reach me at contato@lucasgardini.com.
Disclaimer: auto-type-env is a third-party library and is not affiliated with or endorsed by Node.js or its contributors.