Type vs Interface 어떤것을 써야할까?
interface 타입과 객체 자체에 대한 type 별칭은 많은 점이 비슷하지만, type 별칭보다 더 많은 것을 할 수 있기에 interface를 사용하는 것을 일반적으로 권장합니다. interface는 같은 이름으로 여러 번 선언을 해도 컴파일 시점에서 합쳐지기 때문에 확장성이 좋다. 따라서 일반적으로는 interface를 사용하고 union, tuple 등이 필요한 경우에만 type 별칭을 사용하라는 TypeScript Handbook의 내용은 현재에도 유효하다. -> 예를들어, A.tsx 파일에서 interface test { str1: '1' } B.tsx 파일에서 interface test { str2: '2' } 똑같은 이름의 인터페이스를 중복으로 선언하면 프로젝트가 컴파일 될때 아래와 같이..
Typescript
2020. 4. 13. 16:48
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- rendering scope
- Polyfill
- promise
- reducer
- props
- hydrate
- typescript
- es6
- await
- Next.js
- server side rendering
- reactdom
- webpack
- design system
- return type
- useRef
- atomic design
- mobx
- react hooks
- javascript
- async
- react
- storybook
- computed
- useEffect
- Action
- reflow
- state
- type alias
- Babel
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 | 31 |
글 보관함