I'm reading a bit about declaration merging in TypeScript and I have a hard time grokking the use case for it, specifically for interfaces.
In their documentation, they have this example:
That is, in the example:
interface Cloner { clone(animal: Animal): Animal; } interface Cloner { clone(animal: Sheep): Sheep; } interface Cloner { clone(animal: Dog): Dog; clone(animal: Cat): Cat; }The three interfaces will merge to create a single declaration as so:
interface Cloner { clone(animal: Dog): Dog; clone(animal: Cat): Cat; clone(animal: Sheep): Sheep; clone(animal: Animal): Animal; }
Why would one want to create three separate interfaces instead of the resulting declaration?