Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- for of
- boolean
- 함수선언식
- ELSE
- if else
- javascript
- 프론트엔드
- 속성
- for in
- frontend
- justify-content
- typeof
- 변수
- flex
- 문자열
- 비교연산자
- properties
- 타입
- for
- 반복문
- 조건문
- 함수표현식
- flex-direction
- 화살표함수
- 기초
- flex-wrap
- align-content
- 함수
- Methods
- 논리연산자
Archives
- Today
- Total
하얀 코딩
[TypeScript - 7] Union( | ) / Intersection( & ) 본문
Union
" 또는 "의 의미를 가지고 있으며 기호는 ( | )로 표시 됩니다.
let value: number | string;
value = 10; // OK
value = "hello"; // OK
Intersection
" 병합 "의 의미를 가지고 있으며 기호는 ( & )로 표시 됩니다.
type Person = {
name: string;
age: number;
};
type Employee = {
companyId: number;
role: string;
};
type PersonEmployee = Person & Employee;
위의 예제에서 PersonEmployee는 Person과 Employee의 모든 속성을 갖는 타입이 됩니다.
따라서 PersonEmployee 타입의 변수는 name, age, companyId, role 모두에 접근할 수 있고 모두 사용이 되어야 합니다.
'TypeScript' 카테고리의 다른 글
[TypeScript - 9] 타입 단언(Type Assertion) (0) | 2023.06.06 |
---|---|
[TypeScript - 8] 타입 가드(Type Guard) (0) | 2023.06.06 |
[TypeScript - 6] Object types (객체 타입) - type, interface (0) | 2023.06.06 |
[TypeScript - 5] Object types (객체 타입) - enum, tuple (0) | 2023.06.06 |
[TypeScript - 4] Object types (객체 타입) - object, array, function (0) | 2023.06.06 |