env-type-defs
v2.0.1
Published
Automatically generate TypeScript type definitions for environment variables based on the content of your env files.
Downloads
9
Maintainers
Readme
env-type-defs
A Node.js package to automatically generate TypeScript type definitions for environment variables based on the content of your env files
Features
- Generates TypeScript type definitions from
.envfiles. - Enhances type safety for environment variables in your project.
- Easy to integrate and use in any Node.js project.
Coming Soon
- Support for multiple
.envfiles (e.g.,.env.development, `.env.production - Automatic regeneration of type definitions when
.envfiles change - Supports for Bun and vite env configurations
Installation
Install the package using npm:
npm install env-type-defs --save-devor using yarn:
yarn add env-type-generator --devUsage
- Create a
.envfile in the root of your project with your environment variables
Example:
DB_HOST=localhost
DB_USER=root
DB_PASS=s1mpl3- Run the command to generate the type definitions:
import envTypeDefs from "env-type-defs"You can now call this envTypeDefs() anywhere in your application main entry point.
Running your project will produce a env.d.ts file which automatically autocompletes your environment variables
Contributing
Contributions are welcome! Feel free to open issues or submit pull requests on GitHub.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Issues
If you encounter any issues or have questions, please open an issue on GitHub.
