Skip to content

Commit

Permalink
refactor: some more remove unnecessary type assertion
Browse files Browse the repository at this point in the history
  • Loading branch information
TkDodo committed May 15, 2024
1 parent 9bfd3b7 commit f6c71ad
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
untracked,
} from '@angular/core'
import {
type DefaultError,
type Mutation,
type MutationCache,
type MutationFilters,
Expand All @@ -22,9 +21,7 @@ import type { Injector, Signal } from '@angular/core'

type MutationStateOptions<TResult = MutationState> = {
filters?: MutationFilters
select?: (
mutation: Mutation<unknown, DefaultError, unknown, unknown>,
) => TResult
select?: (mutation: Mutation) => TResult
}

function getResult<TResult = MutationState>(
Expand Down
5 changes: 1 addition & 4 deletions packages/react-query/src/useMutationState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import * as React from 'react'
import { notifyManager, replaceEqualDeep } from '@tanstack/query-core'
import { useQueryClient } from './QueryClientProvider'
import type {
DefaultError,
Mutation,
MutationCache,
MutationFilters,
Expand All @@ -25,9 +24,7 @@ export function useIsMutating(

type MutationStateOptions<TResult = MutationState> = {
filters?: MutationFilters
select?: (
mutation: Mutation<unknown, DefaultError, unknown, unknown>,
) => TResult
select?: (mutation: Mutation) => TResult
}

function getResult<TResult = MutationState>(
Expand Down
11 changes: 2 additions & 9 deletions packages/solid-query/src/useMutationState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { createEffect, createMemo, createSignal, onCleanup } from 'solid-js'
import { replaceEqualDeep } from '@tanstack/query-core'
import { useQueryClient } from './QueryClientProvider'
import type {
DefaultError,
Mutation,
MutationCache,
MutationFilters,
Expand All @@ -13,9 +12,7 @@ import type { QueryClient } from './QueryClient'

type MutationStateOptions<TResult = MutationState> = {
filters?: MutationFilters
select?: (
mutation: Mutation<unknown, DefaultError, unknown, unknown>,
) => TResult
select?: (mutation: Mutation) => TResult
}

function getResult<TResult = MutationState>(
Expand All @@ -26,11 +23,7 @@ function getResult<TResult = MutationState>(
.findAll(options.filters)
.map(
(mutation): TResult =>
(options.select
? options.select(
mutation as Mutation<unknown, DefaultError, unknown, unknown>,
)
: mutation.state) as TResult,
(options.select ? options.select(mutation) : mutation.state) as TResult,
)
}

Expand Down
5 changes: 1 addition & 4 deletions packages/vue-query/src/useMutationState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { useQueryClient } from './useQueryClient'
import { cloneDeepUnref } from './utils'
import type { DeepReadonly, Ref } from 'vue-demi'
import type {
DefaultError,
MutationFilters as MF,
Mutation,
MutationState,
Expand Down Expand Up @@ -51,9 +50,7 @@ export function useIsMutating(

export type MutationStateOptions<TResult = MutationState> = {
filters?: MutationFilters
select?: (
mutation: Mutation<unknown, DefaultError, unknown, unknown>,
) => TResult
select?: (mutation: Mutation) => TResult
}

function getResult<TResult = MutationState>(
Expand Down

0 comments on commit f6c71ad

Please sign in to comment.