Get a Quote Right Now

Edit Template

Extending Interfaces

Interfaces allow you to define the structure of objects. You can extend an interface from another interface to build a new interface that inherits properties from the base interface. This promotes code reuse and allows you to create more specialized interfaces while maintaining a consistent structure.

interface BasicAddress {
name?: string;
street: string;
city: string;
country: string;
postalCode: string;
}

interface AddressWithUnit extends BasicAddress {
unit: string;
}

  1. In this example, AdminUser is an intersection type that combines properties from both Admin and User types.

Share

Leave a Reply

Your email address will not be published. Required fields are marked *