interface IPerson1 {
name: string;
age?: number;
hello(): void;
}
// interface 의 내용을 바탕으로 class 를 만들어낸다.
class Person implements IPerson1 {
name: string;
age?: number | undefined;
constructor(name: string) {
this.name = name;
}
hello(): void {
console.log(`ㅎㅇ! ${this.name} 이라고 합니다!`);
}
}
// interface 이름으로 type 지정해주자 :)
const person: IPerson1 = new Person(`Malza`);