Socket
Book a DemoInstallSign in
Socket

tyenv

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tyenv

An utility for creation types for `process.env` variables and `.env` file

1.2.2
latest
Source
npmnpm
Version published
Maintainers
1
Created
Source

tyenv

NPM version Package Build Coverage Status

An utility for creation types for process.env variables and .env file.

Installation

npm i tyenv

Initial types generation

At the very first time you will have to create a env.d.ts file. It will be located at node_modules/tyenv/lib directory and will include all types for process.env and .env file.

Note

If .env file was updated - this script should be re-run manually to get all new variables with types for your development process.

Add following script to the scripts of your project's package.json file:

"tyenv": "tyenv init"

Then run:

npm run tyenv

Usage

Add import:

// ES6 or TypeScript
import env from 'tyenv';

// CommonJS
const { env } = require('tyenv');

All of the process.env and the .env file variables will be available with types:

'.env' example

# This value will have a 'number' type.
PORT=3000

# This value will have a 'string' type. Quotes ' or " will be removed.
PROJECT='foo-bar'

COMMENT=some-comment # This value will have a 'string' type and this comment will be removed.

# This value will have a 'boolean' type.
IS_JSON=true

Keywords

nodejs

FAQs

Package last updated on 13 Jan 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.