env-type-defs
v1.0.5
Published
Automatically generate TypeScript type definitions for environment variables based on the content of your env files.
Downloads
15
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
.env
files. - Enhances type safety for environment variables in your project.
- Easy to integrate and use in any Node.js project.
Coming Soon
- Support for multiple
.env
files (e.g.,.env.development
, `.env.production - Automatic regeneration of type definitions when
.env
files change - Supports for Bun and vite env configurations
Installation
Install the package using npm:
npm install env-type-defs --save-dev
or using yarn:
yarn add env-type-generator --dev
Usage
- Create a
.env
file 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.