Back to all reviewers

Preserve public API stability

nestjs/nest
Based on 5 comments
TypeScript

When modifying or extending public interfaces, ensure changes maintain backward compatibility and follow proper versioning practices. Key guidelines:

API TypeScript

Reviewer Prompt

When modifying or extending public interfaces, ensure changes maintain backward compatibility and follow proper versioning practices. Key guidelines:

  1. Make interface additions optional: ```typescript // Instead of interface HttpServer { newMethod(): void; }

// Do this interface HttpServer { newMethod?(): void; }


2. Use union types for extending existing types:
```typescript
// Instead of
type Version = string;

// Do this
type Version = string | (string & {}) | ((version: string) => boolean);
  1. When adding new functionality that could break existing implementations:
    • Create a new interface/type that extends the base
    • Add configuration options to enable new features
    • Wait for major version releases for breaking changes
  2. Document version support clearly: ```typescript @Controller({version: ‘2.x’}) class MyController { @Version(‘>=2.5.1’) @Get(‘:id’) newMethod() {}

@Version(‘<2.5.0’) @Get(‘:id’) legacyMethod() {} } ```

These practices ensure API consumers can upgrade safely and maintain compatibility with their existing implementations.

5
Comments Analyzed
TypeScript
Primary Language
API
Category

Source Discussions