gen-ts
gen-ts generates TypeScript declarations for runtime config.
Command syntax
bash
runtime-env [top-level options] gen-ts [command options]Top-level options and ordering
Top-level options are passed before the subcommand and affect gen-ts output:
--schema-file <path>: selects which schema to read.--global-variable-name <name>: sets the generated global declaration target.--watch: watches schema changes and regenerates declarations.
gen-ts uses the current schema and global variable name.
gen-ts command options
--output-file <path>: where declaration output is written.
Default behavior
--schema-filedefault:.runtimeenvschema.json--global-variable-namedefault:runtimeEnv--watchdefault: off- if
--output-fileis omitted: output is written to stdout
Schema-driven declarations reduce mismatch risk between docs, code, schema, and runtime data.
Example
Firebase-shaped schema key with generated declarations:
json
{
"type": "object",
"properties": {
"FIREBASE_CONFIG": {
"type": "object",
"properties": {
"projectId": { "type": "string" },
"apiKey": { "type": "string" }
},
"required": ["projectId", "apiKey"]
}
},
"required": ["FIREBASE_CONFIG"]
}bash
runtime-env --schema-file .runtimeenvschema.json --global-variable-name runtimeEnv gen-ts --output-file ./src/runtime-env.d.ts