Fix RxCollection.cleanup() return type to match TypeScript declaration#8276
Open
Fix RxCollection.cleanup() return type to match TypeScript declaration#8276
Conversation
RxCollection.cleanup() declares Promise<boolean> return type but the cleanup plugin implementation returned Promise<void> because cleanupRxCollection() had no return value and proto.cleanup did not return its result. Now cleanupRxCollection() returns the boolean isDone and proto.cleanup forwards it to the caller. https://claude.ai/code/session_01FduixuM3gfecWVpxMCFSiC
Contributor
|
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.
This PR contains:
Describe the problem you have without this PR
RxCollection.cleanup()is declared in TypeScript to returnPromise<boolean>, wheretrueindicates that all cleanable documents have been removed. However, the cleanup plugin implementation was returningPromise<void>(undefined at runtime) because the result fromcleanupRxCollection()was not being returned.This causes a type-to-runtime mismatch where callers expecting a boolean value receive
undefinedinstead.Changes Made
Fixed return type in
cleanupRxCollection()(src/plugins/cleanup/cleanup.ts):Promise<boolean>falsewhen the collection is closedisDoneat the end of the functionFixed return statement in cleanup plugin (
src/plugins/cleanup/index.ts):RxCollection.cleanup()return type fromPromise<void>toPromise<boolean>returnstatement to propagate the result fromcleanupRxCollection()Added comprehensive test (
test/unit/cleanup.test.ts):cleanup(0)returns a boolean valuetruewhen cleanup completescleanup()without arguments also returns a booleanAdded changelog entry documenting the fix
Test Plan
The added unit test in
test/unit/cleanup.test.tsverifies:cleanup(0)returns a boolean (not undefined)truewhen all deleted documents have been cleaned upcleanup()without arguments also returns a booleanExisting cleanup tests continue to pass, ensuring no regression in cleanup functionality.
https://claude.ai/code/session_01FduixuM3gfecWVpxMCFSiC