Env Typegen - TypeScript Types from .env
Generate TypeScript types from .env files with smart inference. Type-safe environment variables. Optional Zod schema. Free CLI tool.
- License 许可
- MIT
- 最近更新
- 2026-04-05
- Stars
- ★ 7
- Forks
- 1
01 前言 Front Matter
- name
- Env Typegen - TypeScript Types from .env
- description
- Generate TypeScript types from .env files with smart inference. Type-safe environment variables. Optional Zod schema. Free CLI tool.
02 资源文件 1
- 参考文档_meta.json307 B
03 SKILL.md 正文
Env Typegen
Generate TypeScript types from your .env file. Smart type inference for numbers, booleans, URLs.
Installation
npm install -g @lxgicstudios/env-typegen
Commands
Generate Types
npx @lxgicstudios/env-typegen
npx @lxgicstudios/env-typegen .env.local
npx @lxgicstudios/env-typegen -o src/types/env.d.ts
With Zod Schema
npx @lxgicstudios/env-typegen --zod
Example
Input .env:
# Database
DATABASE_URL=postgresql://localhost:5432/db
DB_POOL_SIZE=10
# Server
PORT=3000
DEBUG=true
# API
API_KEY=sk_live_abc123
Output:
export interface Env {
/** Database */
DATABASE_URL: string;
DB_POOL_SIZE: number;
/** Server */
PORT: number;
DEBUG: boolean;
/** API */
API_KEY: string;
}
export function getEnv(): Env {
return {
DATABASE_URL: process.env.DATABASE_URL || '',
DB_POOL_SIZE: Number(process.env.DB_POOL_SIZE),
PORT: Number(process.env.PORT),
DEBUG: ['true', '1', 'yes'].includes(process.env.DEBUG?.toLowerCase() || ''),
API_KEY: process.env.API_KEY || '',
};
}
declare global {
namespace NodeJS {
interface ProcessEnv {
DATABASE_URL: string;
DB_POOL_SIZE: string;
PORT: string;
DEBUG: string;
API_KEY: string;
}
}
}
Type Inference
| Pattern | Type |
|---|---|
PORT=3000 |
number |
DEBUG=true |
boolean |
API_URL=https://... |
string (URL) |
EMAIL=a@b.com |
string (email) |
| Everything else | string |
Options
| Option | Description |
|---|---|
-i, --input |
Input file (default: .env) |
-o, --output |
Output file (default: env.d.ts) |
--zod |
Generate Zod schema too |
--name |
Interface name (default: Env) |
Common Use Cases
Generate for project:
npx @lxgicstudios/env-typegen -o src/types/env.d.ts
With runtime validation:
npx @lxgicstudios/env-typegen --zod -o src/env.ts
Built by LXGIC Studios
04 同仓库更多 Skills
zyfai
Earn yield on any Ethereum wallet on Base, Arbitrum, and Plasma. Use when a user wants passive DeFi yield on their funds. Deploys a non-custodial subaccount (Safe) linked to their EOA, enables automated yield optimization, and lets them deposit/withdraw anytime.
zerion-api
暂无简介
zerion-api-skill
暂无简介
zerion-api-mcp
暂无简介
yahoo-finance-forex
Fetches real-time FOREX news and market data from Yahoo Finance for major currency pairs (EUR/USD, GBP/USD, USD/JPY, etc.). Analyzes sentiment and provides trading context.
yahoo-finance
This skill should be used when the user asks to "get stock prices", "check stock quotes", "look up earnings", "get financial data", "find trending stocks", or needs stock market data from Yahoo Finance.