아주 가끔 인터페이스를 js에 넣고 싶을 때가 있는데 그때 사용하는 것이 class이다.

class Human {
  public name: string;
  public age: number;
  public gender: string;

  constructor(name: string, age: number, gender: string) {
    this.name = name;
    this.age = age;
    this.gender = gender;
  }
}

const sayHi = (person: Human): string => {
  return `Hello ${person.name} you are ${person.age}, you are a ${person.gender}`;
};

const cmlee = new Human('cmlee', 18, 'male');
console.log(sayHi(cmlee));

export {};

좀 코드가 많아 지는 것 같다 ㅠㅠ

만약 react 에서도 class를 사용하기 때문에 아마 class를 사용할 것 같다.