Manual Typing
You can manually specify types without using a schema:
import { loadEnv } from "vkrun";
type EnvTypes = { API_KEY: string; DEBUG: boolean; PORT: number };
const envs = loadEnv<EnvTypes>();Using InferOut<typeof schema>
InferOut<typeof schema> allows loadEnv() to automatically infer types from a schema:
import { schema, loadEnv, InferOut } from "vkrun";
const envSchema = schema().object({
API_KEY: schema().string(),
DEBUG: schema().boolean(),
PORT: schema().number().integer(),
});
type EnvTypes = InferOut<typeof envSchema>;
const envs = loadEnv<EnvTypes>({ schema: envSchema });