# Code/Types Generation
Code generation is dictated by the meta file. This file lives alongside config and schema files.
.app-config.meta.yml
generate:
- { file: 'src/@types/lcdev__app-config/index.d.ts' }
Run the CLI to write the type files.
npx @app-config/cli generate
If you have src/**/*
in your include
of tsconfig.json
, then TypeScript
should be aware of the type of the config
export. Otherwise, you might want
to use typeRoots (opens new window).
There are examples of code generation in each of our example projects (opens new window).
An example of the file that's written is below:
// AUTO GENERATED CODE
// Run app-config with 'generate' command to regenerate this file
import '@app-config/main';
export interface Config {
user?: User;
}
export interface User {
name?: string;
}
// augment the default export from app-config
declare module '@app-config/main' {
export interface ExportedConfig extends Config {}
}
By "augmenting" the module, TypeScript will know that config
has a specific type.
Other options for the meta file:
file
: filepath of code to writename
: export name, mostly for aesthetic reasonsaugmentModule
: if app-config main export should be typedleadingComments
: first couple lines to insert in filerendererOptions
: unstable options passed to quicktype
# Go Support
See App Config in Golang page for more.
# Rust Support
See App Config in Rust page for more.