
Typeconf
Adding types for your configuration
npx create-typeconf-package
1// Define configuration models with TypeSpec
2model ProjectConfig {
3 name: string;
4 modes: Array<string>;
5 pricingCoeffs: Record<float32>;
6}
1// Generate type-safe configs using Typescript
2import {
3 ProjectConfig,
4} from "~/types/all.js";
5
6let config: ProjectConfig = {
7 name: "my-service",
8 modes: ["current", "new_test"],
9 pricingCoeffs: {
10 "london": 0.99,
11 "nyc": 1.25,
12 "sf": 9000.0,
13 },
14};
15
16export default config;
1{
2 "name": "my-service",
3 "modes": [
4 "current",
5 "new_test"
6 ],
7 "pricingCoeffs": {
8 "london": 0.99,
9 "nyc": 1.25,
10 "sf": 9000
11 }
12}
1// Define configuration models with TypeSpec
2model ProjectConfig {
3 name: string;
4 modes: Array<string>;
5 pricingCoeffs: Record<float32>;
6}
1// Generate type-safe configs using Typescript
2import {
3 ProjectConfig,
4} from "~/types/all.js";
5
6let config: ProjectConfig = {
7 name: "my-service",
8 modes: ["current", "new_test"],
9 pricingCoeffs: {
10 "london": 0.99,
11 "nyc": 1.25,
12 "sf": 9000.0,
13 },
14};
15
16export default config;
1{
2 "name": "my-service",
3 "modes": [
4 "current",
5 "new_test"
6 ],
7 "pricingCoeffs": {
8 "london": 0.99,
9 "nyc": 1.25,
10 "sf": 9000
11 }
12}
Configuration is messy. We have many different formats, YAML, JSON, random ini files, not to mention environment variables. It's hard to track changes and easy to break stuff. So we thought let's add types there! Our tool, Typeconf, allows you to define types for your configuration and read it in your code.
Features
Type-Safe Configuration
Write configuration using Typescript and never worry about type issues. Get full IDE support with autocompletion and error checking.
NPM Integration
Share configs between projects using NPM packages. Version control your configuration like code.
Powered by TypeSpec
Define configuration types using TypeSpec format with full VSCode
support. Forget YAMLs and JSON Schemas, get a powerful and expressive way
to describe your configuration schema.
First-Class Types
Read configs from your code with full type safety. Currently supporting TypeScript with more languages coming.
Network Storage
Access your configuration from our distributed storage. Coming soon.
Runtime Performance
Optimized for fast loading and minimal memory footprint. Perfect for serverless environments.
Schema Validation
Coming soon: Validate your configuration against JSON Schema. Built-in support for common formats.
Multi-Language Support
Python, Kotlin, and Swift support coming soon. Write once, use everywhere not only on web, but also on mobile.
Use Cases
model ProductParams { deviceType: string; coefficient: number; isEnabled: boolean; } model ProductFlags { params_by_user_id: Record<ProductParams>; params_by_device: Record<ProductParams>; }
Feature flags and gradual rollouts
With Typeconf you can define product flags based on device type, user id, and whatever else you want.
Infrastructure configs
You can replace tons of hard to support YAMLs with simple configuration in Typescript.
// types model Route { path: string; backend: string; rateLimit: int32; } model APIGatewayConfig { routes: Record<Route>; } // values import { APIGatewayConfig } from "~/types/all.js"; let config: APIGatewayConfig = { routes: { "/user": { path: "/user", backend: "user-service", rateLimit: 1000, }, "/order": { path: "/order", backend: "order-service", rateLimit: 500, }, }, }; export default config;
model Employee { employeeId: string; name: string; email: string; role: string; } model EmployeeInventory { employees: Record<Employee>; }
Inventory storage
You can define Typeconf configs for your data that changes rarely, like employee portal information, device firmware list.