목록STUDY/Typescript (1)
주니어에서 시니어로
[Typescript] type vs interface
진행 중인 리액트 프로젝트를 타입스크립트로 바꾸고 있는데,객체의 타입을 줄 때 어떤건 type으로 주고, 어떤건 interface로 주기에 무슨 차이인가 알아보게 되었다.확장interfaceinterface Person { name: string; age: number;}interface Student extends Person {// 확장(상속) school: string;}const hello: Student = { name: 'hello', age: 11, school: 'world'} typetype Person { name: string; age: number;}type Student = Person & { // 확장(상속) school: string;}const hello: S..
STUDY/Typescript
2024. 11. 18. 10:11