반응형
typescript에서 가장 번거로운건 매개변수별 타입을 정해주는 것입니다.
개인적으로 공통 타입을 만들어 놓고 사용하는 것을 즐기는데요. 그럼 타입끼리 합쳐 새로운 타입을 생성하는건 어떻게 할까요?
type a = {a: number}
type b = {b: number}
type c = a & b
// c = {
// a: number,
// b: number
// }
이상입니다
'개발 > typescript' 카테고리의 다른 글
[Typescript] Module '"react-router-dom"' has no exported member 'useHistory'. (0) | 2022.06.03 |
---|---|
[Typescript] Object is of type 'unknown' (0) | 2022.06.02 |
typescript+pwa 구현하기 (0) | 2021.04.29 |
typescript docs 번역본 #5 (Unions and Intersection Types) (0) | 2021.01.26 |
typescript docs 번역본 #4 (Literal types) (0) | 2021.01.25 |