October 2018
Beginner to intermediate
478 pages
10h 8m
English
Just like in .NET, TypeScript classes can inherit from only one class, but can implement as many interfaces as desired.
Inheritance is defined by using the extends keyword, while interface implementation uses the implements keyword, as follows:
interface Calculator { calc(left: number, right: number): number;}interface Printable { print();}class HistoryCalculator { protected history = []; protected logHistory() { console.log(`current history length: ${this.history.length}`); }}class SumCalculator extends HistoryCalculator implements Calculator, Printable { calc(left: number, right: number): number { this.history.push({left, right}); return left + right; } print() { this.logHistory(); }}const ...Read now
Unlock full access