상태 열거
loading, error, empty, success에서 허용되는 필드를 각각 적는다.
state modeldiscriminated union, generic component, satisfies, as const를 사용하면 런타임 분기보다 먼저 잘못된 UI 조합을 줄일 수 있다.
loading, error, empty, success에서 허용되는 필드를 각각 적는다.
state modelstatus나 kind 같은 고정 필드로 타입 좁히기 기준을 만든다.
discriminator컴포넌트가 받은 item 타입을 onSelect와 renderItem까지 잃지 않게 연결한다.
T flows설정 객체는 satisfies로 shape를 검증하되 literal 타입을 유지한다.
config safetytype LoadState<T> =
| { status: "loading" }
| { status: "error"; message: string }
| { status: "success"; data: T };