Difference between type, interface

steyu·2023년 3월 3일
0
post-thumbnail

1. Name type


둘 다 타입에 이름을 부여해주는 것이지만 type은 모든(any) 타입에 이름을 달아줄 수 있지만, interface는 오직 객체 타입에만 가능하다

2. Expandable


interface의 대부분의 기능들은 type에서도 가능하다
주요 차이점은 type은 새로운 프로퍼티에 열려있지 않다는 것이고, interface는 항상 열려있다.

https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#differences-between-type-aliases-and-interfaces

0개의 댓글