refactor(shared/core): extract InfiniteSource + stricter core tsconfig#35
Merged
refactor(shared/core): extract InfiniteSource + stricter core tsconfig#35
Conversation
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>
📊 Test Coverage Report (vitest)
|
Contributor
There was a problem hiding this comment.
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.
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>
📊 Test Coverage Report (vitest)
|
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
InfiniteSource추출:useInfinitePages의 페이지 로딩 로직을 프레임워크 의존성 없는 순수 TypeScript 클래스(InfiniteSource<T>)로 분리. observer 패턴(subscribe/notify)으로 외부에 상태 변경을 전파하며, Vue·Svelte 등 다른 프레임워크에서도 직접 사용 가능useInfinitePages슬림화: React 훅은InfiniteSource를useRef로 보관하고useState로 상태를 동기화하는 얇은 바인딩 레이어로 축소noUncheckedIndexedAccess,exactOptionalPropertyTypes,noImplicitOverride추가Commits
feat(shared)—InfiniteSource클래스 + 순수 단위 테스트 (React Testing Library 없이 Vitest만으로 검증)refactor(shared)—useInfinitePages를InfiniteSource래퍼로 교체, index 재내보내기chore(core)— tsconfig 옵션 추가,Virtualizerprivate field?:→| undefined수정Test plan
pnpm --filter @scrolloop/shared test— 53 tests passpnpm --filter @scrolloop/core test— 44 tests passpnpm typecheck— 전 패키지 타입 검사 통과🤖 Generated with Claude Code