Back to all reviewers

Preserve API interface stability

nestjs/nest
Based on 5 comments
TypeScript

When modifying or extending public API interfaces, ensure backward compatibility and proper versioning. Follow these guidelines: 1. Make interface additions optional to avoid breaking changes:

API TypeScript

Reviewer Prompt

When modifying or extending public API interfaces, ensure backward compatibility and proper versioning. Follow these guidelines:

  1. Make interface additions optional to avoid breaking changes: ```typescript // Instead of adding required methods interface HttpServer { get(): void; newMethod(): void; // Breaking change! }

// Make additions optional interface HttpServer { get(): void; newMethod?(): void; // Non-breaking change }


2. Support versioning through explicit version types:
```typescript
// Allow flexible version handling
export interface CustomVersioningOptions {
  type: VersioningType.CUSTOM;
  extractor: (request: any) => string | string[];
}

@Controller({
  version: '1',
  versioningOptions: customOptions
})
  1. When evolving interfaces:
    • Add new methods as optional properties
    • Use union types for backward compatibility
    • Document breaking changes for major version releases
    • Consider providing migration paths for deprecated features

This approach maintains API stability while enabling controlled evolution of the interface contract.

5
Comments Analyzed
TypeScript
Primary Language
API
Category

Source Discussions