대수 타입(Algebraic type)
대수 타입(Algebraic type)
대수 타입이란 여러개의 타입을 합성해서 만드는 타입을 말한다.
합집합(Union) 타입
let a: string | number | boolean;
a = 1;
a = "hello";
a = true;
Union 타입으로 배열 타입 정의하기
let arr: (number | string | boolean)[] = [1, "hello", true];
Union 타입과 객체 타입
type Dog = ...
woodstock.hashnode.dev1 min read