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(*): change noop function return type from undefined to void #8299

Merged
merged 9 commits into from
Nov 19, 2024
3 changes: 2 additions & 1 deletion packages/angular-query-experimental/src/providers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
import { QueryClient, onlineManager } from '@tanstack/query-core'
import { isPlatformBrowser } from '@angular/common'
import { isDevMode } from './util/is-dev-mode/is-dev-mode'
import { noop } from './util'
import type { EnvironmentProviders, Provider } from '@angular/core'
import type {
DevtoolsButtonPosition,
Expand Down Expand Up @@ -251,7 +252,7 @@ export function withDevtools(
provide: ENVIRONMENT_INITIALIZER,
multi: true,
useFactory: () => {
if (!isPlatformBrowser(inject(PLATFORM_ID))) return () => {}
if (!isPlatformBrowser(inject(PLATFORM_ID))) return noop
const injector = inject(Injector)
const options = computed(() =>
runInInjectionContext(injector, () => optionsFn?.() ?? {}),
Expand Down
4 changes: 3 additions & 1 deletion packages/query-async-storage-persister/src/utils.ts
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
export function noop(): void {}
export function noop(): void
export function noop(): undefined
export function noop() {}
6 changes: 3 additions & 3 deletions packages/query-core/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ export type QueryTypeFilter = 'all' | 'active' | 'inactive'

export const isServer = typeof window === 'undefined' || 'Deno' in globalThis

export function noop(): undefined {
return undefined
}
export function noop(): void
export function noop(): undefined
export function noop() {}

export function functionalUpdate<TInput, TOutput>(
updater: Updater<TInput, TOutput>,
Expand Down
2 changes: 1 addition & 1 deletion packages/query-sync-storage-persister/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export function createSyncStoragePersister({

return {
persistClient: noop,
restoreClient: () => undefined,
restoreClient: noop,
removeClient: noop,
}
}
Expand Down
4 changes: 3 additions & 1 deletion packages/query-sync-storage-persister/src/utils.ts
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
export function noop(): void {}
export function noop(): void
export function noop(): undefined
export function noop() {}

Check warning on line 3 in packages/query-sync-storage-persister/src/utils.ts

View check run for this annotation

Codecov / codecov/patch

packages/query-sync-storage-persister/src/utils.ts#L3

Added line #L3 was not covered by tests
4 changes: 2 additions & 2 deletions packages/svelte-query/src/createBaseQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { notifyManager } from '@tanstack/query-core'
import { useIsRestoring } from './useIsRestoring.js'
import { useQueryClient } from './useQueryClient.js'
import { isSvelteStore } from './utils.js'
import { isSvelteStore, noop } from './utils.js'
import type {
QueryClient,
QueryKey,
Expand Down Expand Up @@ -66,7 +66,7 @@
QueryObserverResult<TData, TError>
>(isRestoring, ($isRestoring, set) => {
const unsubscribe = $isRestoring
? () => undefined
? noop

Check warning on line 69 in packages/svelte-query/src/createBaseQuery.ts

View check run for this annotation

Codecov / codecov/patch

packages/svelte-query/src/createBaseQuery.ts#L69

Added line #L69 was not covered by tests
: observer.subscribe(notifyManager.batchCalls(set))
observer.updateResult()
return unsubscribe
Expand Down
4 changes: 2 additions & 2 deletions packages/svelte-query/src/createQueries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { derived, get, readable } from 'svelte/store'
import { useIsRestoring } from './useIsRestoring.js'
import { useQueryClient } from './useQueryClient.js'
import { isSvelteStore } from './utils.js'
import { isSvelteStore, noop } from './utils.js'
import type { Readable } from 'svelte/store'
import type { StoreOrVal } from './types.js'
import type {
Expand Down Expand Up @@ -253,7 +253,7 @@

const result = derived([isRestoring], ([$isRestoring], set) => {
const unsubscribe = $isRestoring
? () => undefined
? noop

Check warning on line 256 in packages/svelte-query/src/createQueries.ts

View check run for this annotation

Codecov / codecov/patch

packages/svelte-query/src/createQueries.ts#L256

Added line #L256 was not covered by tests
: observer.subscribe(notifyManager.batchCalls(set))

return () => unsubscribe()
Expand Down
Loading