Skip to content

refactor(shared/core): extract InfiniteSource + stricter core tsconfig#35

Merged
zaewc merged 4 commits intodevelopfrom
refactor/infinite-source
Mar 30, 2026
Merged

refactor(shared/core): extract InfiniteSource + stricter core tsconfig#35
zaewc merged 4 commits intodevelopfrom
refactor/infinite-source

Conversation

@zaewc
Copy link
Copy Markdown
Owner

@zaewc zaewc commented Mar 29, 2026

Summary

  • InfiniteSource 추출: useInfinitePages의 페이지 로딩 로직을 프레임워크 의존성 없는 순수 TypeScript 클래스(InfiniteSource<T>)로 분리. observer 패턴(subscribe/notify)으로 외부에 상태 변경을 전파하며, Vue·Svelte 등 다른 프레임워크에서도 직접 사용 가능
  • useInfinitePages 슬림화: React 훅은 InfiniteSourceuseRef로 보관하고 useState로 상태를 동기화하는 얇은 바인딩 레이어로 축소
  • core tsconfig 강화: noUncheckedIndexedAccess, exactOptionalPropertyTypes, noImplicitOverride 추가

Commits

  1. feat(shared)InfiniteSource 클래스 + 순수 단위 테스트 (React Testing Library 없이 Vitest만으로 검증)
  2. refactor(shared)useInfinitePagesInfiniteSource 래퍼로 교체, index 재내보내기
  3. chore(core) — tsconfig 옵션 추가, Virtualizer private field ?:| undefined 수정

Test plan

  • pnpm --filter @scrolloop/shared test — 53 tests pass
  • pnpm --filter @scrolloop/core test — 44 tests pass
  • pnpm typecheck — 전 패키지 타입 검사 통과

🤖 Generated with Claude Code

zaewc and others added 3 commits March 30, 2026 08:52
Extract pagination logic into a pure TypeScript class with no framework
dependencies, enabling reuse across React, Vue, Svelte, and other
consumers via a subscribe/notify observer pattern.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
useInfinitePages is now a thin React binding that delegates all state
management to InfiniteSource. Export InfiniteSource from the package
index so non-React consumers can use it directly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add noUncheckedIndexedAccess, exactOptionalPropertyTypes, and
noImplicitOverride to packages/core/tsconfig.json to catch a broader
class of type errors at compile time. Update Virtualizer private fields
from optional chaining (?:) to explicit union (| undefined) to satisfy
exactOptionalPropertyTypes.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

📊 Test Coverage Report (vitest)

Package Statements Branches Functions Lines
@scrolloop/core 218/218 (100%) 53/53 (100%) 25/25 (100%) 218/218 (100%)
@scrolloop/react 420/715 (58.74%) 73/89 (82.02%) 5/17 (29.41%) 420/715 (58.74%)
@scrolloop/react-native 0/233 (0%) 1/4 (25%) 1/4 (25%) 0/233 (0%)
@scrolloop/shared 178/178 (100%) 54/54 (100%) 14/14 (100%) 178/178 (100%)

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new InfiniteSource class to centralize paginated data management and refactors the useInfinitePages hook to utilize this class. It also strengthens the project's TypeScript configuration by enabling stricter flags like noUncheckedIndexedAccess and exactOptionalPropertyTypes. Feedback was provided regarding the initialization of the InfiniteSource instance within the useInfinitePages hook, recommending the use of a useState lazy initializer to avoid side effects during the rendering phase.

Comment thread packages/shared/src/hooks/useInfinitePages.ts Outdated
Replace useRef + render-phase conditional assignment with useState lazy
initializer. useState guarantees a single instance per mount and avoids
side effects during render, making the hook safe under React Strict Mode.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

📊 Test Coverage Report (vitest)

Package Statements Branches Functions Lines
@scrolloop/core 218/218 (100%) 53/53 (100%) 25/25 (100%) 218/218 (100%)
@scrolloop/react 420/715 (58.74%) 73/89 (82.02%) 5/17 (29.41%) 420/715 (58.74%)
@scrolloop/react-native 0/233 (0%) 1/4 (25%) 1/4 (25%) 0/233 (0%)
@scrolloop/shared 176/176 (100%) 54/54 (100%) 14/14 (100%) 176/176 (100%)

@zaewc zaewc merged commit ca9fa69 into develop Mar 30, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant