abstract class Category {
categoryName: string;
constructor(name: string) {
this.categoryName = name;
}
display(): void {
console.log(this.categoryName);
}
abstract find(name: string): Category;
}
class Brand extends Category {
brandCode: number;
constructor(name: string, code: number) {
super(name); // must call super()
this.brandCode = code;
}
find(name: string): Category {
// execute AJAX request to find an employee from a db
return new Brand(name, 1);
}
}
let brand: Category = new Brand('James', 100);
brand.display(); //James
let brand2: Category = brand.find('Steve');