July 2017
Intermediate to advanced
454 pages
10h 1m
English
Class type interfaces define the contract for classes. A class that implements an interface should meet the requirement of the interface:
interface CustomerInterface {
id: number;
firstName: string;
lastName: string;
addCustomer(firstName: string, lastName: string);
getCustomer(id: number): Customer;
}
class Customer implements CustomerInterface {
id: number;
firstName: string;
lastName: string;
constructor() { }
addCustomer(firstName: string, lastName: string) {
// code to add customer
}
getCustomer(id: number): Customer {
return this;
}
}
The class type interface only deals with public members of the class. So, it is not possible to add private members to the interface.
Read now
Unlock full access