refactor: 공통 SavedItemBase 추출 (PR-D)#73
Merged
Merged
Conversation
피드와 유튜브 아이템이 동일한 의미의 공통 필드 10개(id, sourceId, title, description, thumbnailUrl, publishedAt, isRead, isBookmarked, note, pinnedAt) 를 각자 선언하고 있었음. InlineNote / 북마크 / 핀 토글 / 읽음 토글 같은 공통 UI가 두 타입을 유사한 방식으로 소비 중이라 base interface 로 통합. ## 변경 - 신규: `packages/web/src/lib/types/saved-item.ts` — `SavedItemBase` 정의 - `FeedItemData extends SavedItemBase`: 도메인 필드만 유지 (url, category, tags, collectedAt, sourceName). sourceId 는 string 로 narrow. - `YoutubeItemData extends SavedItemBase`: 도메인 필드만 유지 (videoId, status, channelName, oneLiner, summarySource, keywords, duration) - 신규: `__tests__/saved-item-base.test.ts` — 두 concrete 타입이 base 와 구조적으로 호환됨을 lock 하는 회귀 가드 (3 tests) ## 불변 - 런타임 동작 일절 변동 없음 (타입만 재구성) - 필드 이름/타입 완전 동일 (sourceId는 FeedItemData에서만 non-null로 narrow) - 컴파일 시 TS structural typing 덕분에 모든 기존 consumer 호환 - 257 tests 통과 (기존 254 + 새 3), typecheck 통과 ## 가치 - SavedItemBase 를 받아 동작하는 공통 유틸(예: 향후 핀 토글 헬퍼, 북마크 헬퍼)을 한 곳에 쓸 수 있음 - Drift 발생 시(예: 한쪽만 필드 rename) CI 에서 즉시 실패 - 새 아이템 타입 추가 시(예: 노트, 팟캐스트) 같은 base 로 시작 가능 Co-Authored-By: Claude <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
피드와 유튜브 아이템이 동일 의미의 공통 필드 10개를 각자 선언하고 있었음. 공통 UI(InlineNote / 북마크 / 핀 토글 / 읽음 토글)가 두 타입을 유사하게 소비 중이라 base interface 로 통합.
변경
불변
가치
Test plan
Follow-up
PR-E (컴포넌트 완전 분리: feed-list + youtube-feed) 예정.
🤖 Generated with Claude Code