Summary
Add support for loading configuration files written in TypeScript.
Motivation
Many modern projects use TypeScript as their primary language. Requiring users to write configuration files in JavaScript introduces friction and breaks consistency within TypeScript-based codebases. Supporting TypeScript config files improves developer experience and aligns with common ecosystem practices.
Definition of done
Proposed approach
- Introduce a mechanism to load TypeScript config files at runtime.
- Use tools such as ts-node, tsx, or a lightweight transpilation step (e.g., esbuild-register) to execute .ts files.
- Detect config file extensions (e.g., .ts, .mts, .cts) and apply the appropriate loader.
- Normalize the exported config (e.g., handle default export consistently).
- Ensure compatibility with both ESM and CommonJS environments.
- Document any required peer dependencies or setup steps for users.
Additional context
Example of a TypeScript config file:
import type { Config } from 'flagly';
const config: Config = {
flagSource: (key, defaultValue) => defaultValue,
baseEnv: {},
};
export default config;
Consider whether to:
- Require users to install a runtime (e.g., tsx)
- Or provide a built-in lightweight loader
This decision impacts usability, performance, and maintenance.
Related issues
Summary
Add support for loading configuration files written in TypeScript.
Motivation
Many modern projects use TypeScript as their primary language. Requiring users to write configuration files in JavaScript introduces friction and breaks consistency within TypeScript-based codebases. Supporting TypeScript config files improves developer experience and aligns with common ecosystem practices.
Definition of done
Proposed approach
Additional context
Example of a TypeScript config file:
Consider whether to:
This decision impacts usability, performance, and maintenance.
Related issues