Effective Typescript#4 타입 설계
아이템28. 유효한 상태만 표현하는 타입을 지향하기
아래의 예시는 웹 애플리케이션의 전체 상태에 대한 타입 설계 입니다. 웹 페이지의 상태가 될 수 있는 값들을 정확하게 파악하고 모호함(예시: A상태이자 B상태인)이 없도록 명확하게 구분했습니다.
interface RequestPending {
state: 'pending';
}
interface RequestError {
state: 'error';
error: strin...
blog.lyunho.kim5 min read