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 | 29 | 30 | 31 |
Tags
- if else
- 기초
- 함수표현식
- javascript
- 논리연산자
- flex-direction
- typeof
- 프론트엔드
- 함수선언식
- 변수
- 비교연산자
- 함수
- boolean
- for in
- ELSE
- 타입
- 문자열
- properties
- for
- Methods
- for of
- flex-wrap
- 반복문
- 조건문
- flex
- 화살표함수
- align-content
- frontend
- justify-content
- 속성
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 |