Language/Typescript
[ Typescript ] class type 지정
kitez
2021. 12. 18. 16:55
class type 지정
! constructor함수는 return type이 항상 object이기 때문에 return type을 지정하면 안된다.
class Person{
let name : string;
constructor(a : string){
this.name = a;
}
};
Person.prototype.greet = function(a : sring) : void{
console.log("hello" + a);
}
let Minseo = new Person("Minseo");
console.log(Minseo.name); // result : Minseo
// Person의 자식들은 모두 greet이라는 함수를 사용할 수 있다.
728x90