티스토리 뷰
intersection 과 union type의 개념이 항상 헷갈리다가 모처럼 정리해보기로 했다.
우선 결론 부터 말하자면,
intersection ( & ): 두 가지 type 을 전부 만족시켜야 한다. interface의 extends 키워드와 같은 효과를 지닌다.
union ( | ): 두 가지 type중 한가지만 만족시켜도 된다! ( 물론 둘 다 만족시켜도 된다.)
type a = {
a_one: string
a_two: string
}
type b = {
b_one: number
b_two: number
}
// 가능
const _c: a | b = {
a_one: "_a",
a_two: "_aa",
}
// 불가능
const c: a & b = {
a_one: "_a",
a_two: "_aa",
}
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- next.js import glsl
- attempted import error: bvh_struct_definitions' is not exported from './gpu/bvhshaderglsl.js' (imported as 'bvhshaderglsl').
- 394. decode string javascript
- rollup react.js npm
- react 3d
- vue3
- vue
- leva
- webpack glsl
- react fiber 3d
- react three fiber leva
- 394 decode string
- eslint
- [leetcode] 394. decode string js
- [leetcode] 394. decode string
- react three fiber
- react 3d 에니메이션
- rollup ts react npm
- Vue.js
- typescript gsls
- react 3d text
- next.js glsl
- react leva
- react glsl
- rollup typescript react
- rollup typescript
- 394. decode string js
- ts glsl
- react 3d animation
- three.js leva
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
글 보관함