Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(query-core): type override subscribe in InfiniteQueryObserver more clearly #7914

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions packages/query-core/src/infiniteQueryObserver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
hasPreviousPage,
infiniteQueryBehavior,
} from './infiniteQueryBehavior'
import type { Subscribable } from './subscribable'
import type {
DefaultError,
DefaultedInfiniteQueryObserverOptions,
Expand Down Expand Up @@ -38,9 +39,9 @@ export class InfiniteQueryObserver<
TQueryKey
> {
// Type override
subscribe!: (
listener?: InfiniteQueryObserverListener<TData, TError>,
) => () => void
subscribe!: Subscribable<
InfiniteQueryObserverListener<TData, TError>
>['subscribe']
Comment on lines +42 to +44
Copy link
Contributor Author

@manudeli manudeli Aug 18, 2024

Choose a reason for hiding this comment

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

It's trivial. but when doing type overriding, I want to use Subscribable and make it clearer to override while keeping the constraints of Subscribable, so I think it reduces the possibility of making constraint mistakes.

Copy link
Collaborator

Choose a reason for hiding this comment

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

shouldn't we do the same for other type overrides, like fetch a couple of lines below as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried this on other type overrides(getCurrentResult, fetch) in ccb4a62


// Type override
getCurrentResult!: () => InfiniteQueryObserverResult<TData, TError>
Expand Down
Loading