1. 타입 추론
let a = 10;
const b = 20;
const c = [1, 2];
const d = [1, "hello", true];
const e = [1, 2, 3] as const;
type A = number;
type B = number;
type C = number[];
type D = (number | string | boolean)[];
type E = [1, 2, 3];
2. 조건을 만족하는 타입 정의
- Animal 타입은 Dog 타입일수도 Cat 타입일수도 있다.
- DogCat 타입은 Dog이자 Cat이다.type Dog = { name: string; color: string; }; type Cat = { name: string; age: number; };
type Animal = Dog | Cat;
type DogCat = Dog & Cat;'TIL' 카테고리의 다른 글
| spread와 rest (0) | 2025.10.31 |
|---|---|
| 구조 분해 할당 (0) | 2025.10.31 |
| [TS] 타입 추론 (0) | 2025.10.31 |
| [TS] 대수 타입 (0) | 2025.10.31 |
| [TS] void와 never (0) | 2025.10.28 |
