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
and:
- Create a
Timestampsinterface withcreatedAt: DateandupdatedAt: Date - Create an
Entityinterface that extendsTimestampsand addsid: string - Create
UserandProductinterfaces that extendEntitywith their own fields (name/emailandname/price) - Create an
AuditLoginterface that extendsTimestamps(notEntity) withaction: stringanduserId: string - Create sample
user,product,log, andentityvalues and export them by name
Completion criteria
- Named exports:
user,product,log,entity user/productincludeid, timestamps (Date), and their own fieldsloghas timestamps plusaction/userId(noidrequired)entityhasidpluscreatedAt/updatedAtasDates


