![](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FcVFMFf%2FbtrXPV0Yhkj%2FcktUUK977aSSiVjqGNJBqK%2Fimg.png)
[TS] type과 interface 차이
·
🍞 Front-End/TypeScript
type과 interface 키워드는 타입을 정의할 때 사용한다. 보통 React app 내에서는 component에 넘겨주는 props의 타입을 정의하기 위해 아래와 같이 사용하곤 한다. type GreetingsProps = { //type 사용해도 정상 작동 name: string; }; interface GreetingsProps { //interface 사용해도 정상 작동 name: string; }; const Greetings = ({ name }: GreetingsProps) => ( Hello, {name} ); 이 두 키워드 둘 다 타입 정의라는 비슷한 역할을 하기 때문에 차이점과 언제, 어느 상황에 어떤 키워드를 사용하는 것이 적절할지 짚고 넘어갈 필요가 있다. ❗ 뭐가 다른 걸까? ..