Skip to content
TypeScript

Deklarations-Zusammenführung

Mehrere Deklarationen mit demselben Namen zusammenführen.

#merge#declaration

Code

typescript
interface Box {
  width: number;
}

interface Box {
  height: number;
}

// After merging
const box: Box = { width: 10, height: 20 };

// Function merging
function fn(x: number): number;
function fn(x: string): string;
function fn(x: any): any { return x; }

// Namespace merging into class
class Counter {}
namespace Counter {
  export const instances = 0;
}