Back to all reviewers

Flexible configuration design

axios/axios
Based on 2 comments
TypeScript

Design configuration interfaces to be flexible and extensible rather than overly specific. When creating configuration objects, make configuration parameters optional when possible with sensible defaults and allow for arbitrary additional properties rather than creating specific fields for custom configurations.

Configurations TypeScript

Reviewer Prompt

Design configuration interfaces to be flexible and extensible rather than overly specific. When creating configuration objects:

  1. Make configuration parameters optional when possible with sensible defaults
  2. Allow for arbitrary additional properties rather than creating specific fields for custom configurations

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.

2
Comments Analyzed
TypeScript
Primary Language
Configurations
Category

Source Discussions