Extending Interfaces

Extending Interfaces
πŸ‘¨β€πŸ’Ό Interfaces can extend other interfaces, inheriting their properties. This is cleaner than copying properties manually.
interface Animal {
	name: string
}

interface Dog extends Animal {
	breed: string
}

// Dog has both name and breed
const dog: Dog = { name: 'Rex', breed: 'German Shepherd' }
🐨 Open
index.ts
and:
  1. Create a base Entity interface with common fields
  2. Extend it to create User and Product interfaces
  3. Use multiple inheritance with extends A, B

Please set the playground first

Loading "Extending Interfaces"
Loading "Extending Interfaces"