interface는 js로 컴파일 되지 않는다.
interface 대신에 class를 쓴다.
class Human {
public name: string;
public age: number;
public gender: string;
constructor(name: stiring, age: number, gender: string) {
this.name = string;
this.age = number;
this.gender = string;
}
}
const daniel = new Human("Daniel", 30, "male");
const sayHi = (person): string => {
return `Hello ${person.name}, you are ${person.age}, you are a ${person.gender}!`;
};
console.log(sayHi(daniel));
export {};
index.js에서는 접근 제한자는 없는데 js에서 컴파일 하지 않기 때문이다.
'Uber Eats' 카테고리의 다른 글
# 3-0 Nest.js (0) | 2021.02.11 |
---|---|
# 2-5 TypeScript - BlockChain (0) | 2021.02.11 |
# 2-3 TypeScript - 파라미터에 Object 넘기기 (0) | 2021.02.10 |
# 2-2 TypeScript 특징 및 컴파일 위치 및 타입스크립트 설정 (0) | 2021.02.10 |
# 2-1 TypeScript - 특징 및 규칙 (0) | 2021.02.10 |