Once you have defined your configuration schema and values, you can read them in
your application. TypeConf provides a simple and type-safe way to access your
configurations.
To read your configurations, it’s pretty straightforward, use the readConfig function:
Copy
import { ConfigType } from "your-config-package";import { readConfig } from "@typeconf/sdk";// Path to your config without extensionconst config: ConfigType = readConfig("path/to/config-dir/my-params");
The readConfigFromFile function returns your configuration object with full
type safety based on your schema.
One of TypeConf’s key features is complete type safety. Your IDE will provide
full autocomplete and type checking:
Copy
const config: ConfigType = readConfig("path/to/config-dir/my-params");// TypeScript knows the exact type of your configconfig.database.host; // ✅ Type safeconfig.nonexistent; // ❌ TypeScript error