@placeholdersoft/typed-env
Version:
typed-env can help us better handle environment variables
20 lines (19 loc) • 686 B
TypeScript
declare type EnvBoxValueType = string | undefined;
declare type DefinedAs<T, U> = T extends undefined ? U | undefined : U;
export interface Dict<T> {
[key: string]: T | undefined;
}
export declare class EnvBox<T extends EnvBoxValueType> {
readonly name: string;
private readonly value;
constructor(name: string, value: T);
required(): EnvBox<NonNullable<T>>;
optional(): EnvBox<T>;
default(value: string): EnvBox<string>;
nonEmpty(): EnvBox<NonNullable<T>>;
toBoolean(): boolean;
toInt(radix?: number): DefinedAs<T, number>;
toString(): T;
static of<T extends string>(name: T, env: Dict<string>): EnvBox<string | undefined>;
}
export {};