HOWTO · TypeScript
How to Extend Type in TypeScript
Learn how TypeScript interfaces extend other interfaces and how type aliases compose object shapes.
On this page
In TypeScript, use extends when one interface should inherit another interface’s members. A type alias cannot use that declaration form, but object shapes can be composed with an intersection type using &. The approaches overlap for many object shapes, but they are not identical: interfaces support declaration merging, while intersections combine types and can produce an unusable property when same-named members conflict.
Extend an interface in TypeScript
An extending interface keeps the base members and adds its own requirements. For example, interface Project { submit(data: string): boolean; queue(data: string): boolean; } can be extended with interface ProjectManagement extends Project { submitRequirements(data: string, id: number): boolean; }. A value typed as ProjectManagement must provide all three methods. The extends keyword describes a relationship between interfaces; it does not supply method implementations.
The following JavaScript example makes the resulting object shape visible:
const projectManagement = {
submit(data) {
return data.length > 0;
},
queue(data) {
return data.length > 0;
},
submitRequirements(data, id) {
return data.length > 0 && id > 0;
},
};
console.log(projectManagement.submitRequirements("Roadmap", 7));
true
This JavaScript object demonstrates the three method implementations, but JavaScript itself does not check the TypeScript interface. If you only need to combine object shapes, a type alias can express a similar result as type ProjectManagement = Project & { submitRequirements(data: string, id: number): boolean; }. Prefer interface extension for an interface contract that may be extended or merged; use an intersection when composing aliases or other types.
Extend multiple interfaces in TypeScript
An interface can extend several interfaces by listing their names after extends, separated by commas. For example, interface HasId { id: number; }, interface HasLabel { label: string; }, and interface SelectableItem extends HasId, HasLabel { selected: boolean; } define a combined contract with three distinct properties. A SelectableItem value must provide id, label, and selected.
This is useful when independently defined capabilities need to form one object contract. If two base interfaces declare the same property with incompatible types, TypeScript cannot form a valid extending interface from them. Align the declarations or choose a different model. With type aliases, intersections also combine members, but conflicting property types can make the resulting property impossible to satisfy rather than resolving the conflict automatically.
Extend a class with an interface in TypeScript
An interface may extend a class and inherit its instance members. When the class exposes only public members, an unrelated class can implement the resulting interface by providing the same public shape. Private or protected members add an origin constraint: an implementing class must inherit those members from the class named in the interface’s extends clause.
For example, class Key { private value = true; } followed by interface Lock extends Key { enable(): void; } makes Key’s private member part of the required instance type, even though code using Lock cannot access value. class FingerPrint extends Key implements Lock { enable(): void {} } is valid because FingerPrint inherits that exact private member from Key. An unrelated class Unrelated implements Lock { enable(): void {} } is rejected: declaring a separate private member with the same name does not make it the member inherited from Key.
Use this pattern when the class relationship is intentional. For a public-only contract, implementing an interface directly is usually simpler. Interface extension checks the class’s instance shape at compile time; it does not copy the class’s implementation into the interface or into an implementing class.