Class type interfaces define the contract for classes. A class that implements an interface should meet the requirements 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): void {
// code to add customer
}
getCustomer(id: number): Customer {
// code to return customer where the id match with id parameter
}
}
The class type interface only deals with public members of the class. So, it is not possible to add private members to the interface.