Design configuration interfaces to be flexible and extensible rather than overly specific. When creating configuration objects:
Example - Instead of this:
export interface AxiosRequestConfig<D = any> {
// other properties...
customConfig?: Record<string, any>;
}
// Required configuration parameter
getUri(config: AxiosRequestConfig): string;
Do this:
export interface AxiosRequestConfig<D = any> {
// other properties...
[key: string]: any; // Allow arbitrary properties
}
// Optional configuration parameter
getUri(config?: AxiosRequestConfig): string;
This approach allows consumers to extend configurations naturally without requiring interface changes for each new use case, while maintaining backward compatibility through sensible defaults.
Enter the URL of a public GitHub repository