February 2019
Beginner
694 pages
18h 4m
English
As an example of interface inheritance, consider the following TypeScript code:
interface IBase {
id: number | undefined;
}
interface IDerivedFromBase extends IBase {
name: string | undefined;
}
class InterfaceInheritanceClass implements IDerivedFromBase {
id: number | undefined;
name: string | undefined;
}
We start with an interface called IBase, which defines an id property, of type number or undefined. Our second interface definition, IDerivedFromBase, extends (or inherits) from IBase, and therefore automatically includes the id property. The IDerivedFromBase interface then defines a name property, of type string or undefined. As the IDerivedFromBase interface inherits from IBase, it therefore actually has two ...
Read now
Unlock full access