Categorias
iiiiii
Herencia Clases Typescript
Descripcion
Herencia Clases Typescript
javascript
(()=>{
// no aplicando responsabilidad unica
type Gender = 'M'|'F';
interface PersonaProps{
name:string,
gender:Gender,
bithdat:Date
}
class Persona{
public name:string;
public gender:string;
public bithdat:Date;
constructor({name,gender,bithdat}:PersonaProps){
this.name =name;
this.gender =gender;
this.bithdat =bithdat;
}
}
interface UserProps{
email:string,
role:string,
name:string,
gender:Gender,
bithdat:Date
}
class Usuario extends Persona{
public lastAccess:Date;
public email:string;
public role:string;
constructor({email,role,name,gender,bithdat}:UserProps){
super({name,gender,bithdat});
this.email =email;
this.role =role;
this.lastAccess = new Date();
}
}
interface userSetingProp{
workingDirec:string,
lastFolderDate:string,
email:string,
role:string,
name:string,
gender:Gender,
bithdat:Date
}
class userSetings extends Usuario{
public workingDirec:string;
public lastFolderDate:string;
constructor ({workingDirec,lastFolderDate,email,role,name,gender,bithdat}:userSetingProp){
super({email,role,name,gender,bithdat});
this.workingDirec = workingDirec;
this.lastFolderDate = lastFolderDate;
}
}
let newUserSetging = new userSetings({
workingDirec:'./home/user',
lastFolderDate:'./home/user/filters',
email:'gomezhtml@gmail.com',
role:'ADMIN',
name:'julian',
gender:'M',
bithdat: new Date('2023-01/01')
}
);
console.log(newUserSetging);
})();