---
type: snippet
tags: [typescript, documentation, discriminated-union]
status: release
ctime: 2025-12-29
mtime: 2025-12-29
---

TypeScript Discriminated Union 문서화 딜레마

```typescript
// 개발: 타입 안전, IDE 자동완성, 명확한 의도
type Button =
  | { type: 'submit'; color: string }
  | { type: 'reset'; text: string }
```

```markdown
<!-- 문서화: 조건부 속성 설명 어려움, 테이블 복잡, 예시 다수 필요 -->

| 속성  | 타입                | 조건                    |
| ----- | ------------------- | ----------------------- |
| type  | 'submit' \| 'reset' | 필수                    |
| color | string              | type='submit'일 때 필수 |
| text  | string              | type='reset'일 때 필수  |
```

---

- 자세한 타입 정의는 TypeScript 정의 파일 참고
- [typedoc](https://typedoc.org/), [api-extractor](https://api-extractor.com/pages/overview/intro/)로 자동 생성
