@karmaniverous/get-dotenv
    Preparing search index...

    Function defineGetDotenvConfig

    • Define a strongly‑typed get‑dotenv configuration document for JS/TS authoring.

      This helper is compile‑time only: it returns the input unchanged at runtime, but enables rich TypeScript inference for vars, envVars, and dynamic, and validates property names and value shapes as you author the config.

      Schema-driven overload (preferred): when cfg.schema is a Zod schema, Vars is inferred from the schema's input type (z.input<S>) instead of an explicit type parameter, so dynamic function parameters need no Vars annotation. The schema's input must be string-valued (ProcessEnv- compatible, optional allowed); a schema that coerces from a non-string input is a type error. See ProcessEnvZodSchema.

      Legacy overload: defineGetDotenvConfig<Vars, Env>() keeps compiling unchanged for configs that declare Vars explicitly (with or without a schema, including a non-Zod validator that merely exposes safeParse).

      Type Parameters

      • S extends ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>

        The config's Zod schema type (schema-driven overload only). Inferred from cfg.schema; do not supply explicitly.

      • Env extends string = string

        Allowed environment names used for envVars (defaults to string).

      Parameters

      Returns Omit<GetDotenvConfig<AsProcessEnv<input<S>>, Env>, "schema"> & { schema: S }

      The same cfg value, with its type preserved for inference.

      • schema: S

        The config's Zod object schema, unchanged.

    • Legacy overload: see defineGetDotenvConfig's main documentation.

      Type Parameters

      • Vars extends ProcessEnv

        The string‑valued env map your project uses (for example, { APP_SETTING?: string }). Keys propagate to dynamic function arguments.

      • Env extends string = string

        Allowed environment names used for envVars (defaults to string).

      • T extends GetDotenvConfig<Vars, Env> = GetDotenvConfig<Vars, Env>

        The full config type being produced (defaults to GetDotenvConfig<Vars, Env>). This type parameter is rarely supplied explicitly.

      Parameters

      • cfg: T & (T extends { schema: TS } ? { schema: ProcessEnvZodSchema<TS> } : unknown)

        The configuration object literal.

      Returns T

      The same cfg value, with its type preserved for inference.