Modules
As our applications scale and grow, there will be a time when we need to organize our code better and make it sustainable and reusable. Modules are a great way to accomplish these tasks, so let's look at how they work and how we can implement them in our application.
In the Types section, we learned how to create a class that extends from another class:
class User {
private firstName: string = '';
private lastName: string = '';
private isActive: boolean = false;
constructor(firstName: string, lastName: string, isActive: boolean = true) {
this.firstName = firstName;
this.lastName = lastName;
this.isActive = isActive;
}
getFullname(): string {
return `${this.firstName} ${this.lastName}`;
}
get active(): boolean {
return this.isActive;
}
}
class Customer extends User {
taxNumber: number;
constructor(firstName: string, lastName: string) {
super(firstName, lastName);
}
}
Having both classes in the same file...