amplitude/redux-query

useMutation error after Typescript update

Closed this issue · 1 comments

Hello,

I am using the useMutation hook like so:

const [, setSomethingMutation] = useMutation((somethingId: string) =>
  setSomething({ id: somethtingId })
);

When we recently updated our Typescript, it started throwing a weird error:

Argument of type '(somethingId: string) => QueryConfig<TEntities>' is not assignable to parameter of type 'MutationQueryConfigFactory<unknown>'.
  Call signature return types 'QueryConfig<TEntities>' and 'QueryConfig<TEntities>' are incompatible.
    The types returned by 'transform(...)' are incompatible between these types.
      Type 'Partial<TEntities>' is not assignable to type 'Partial<TEntities>'. Two different types with this name exist, but they are unrelated.
        Type 'keyof TEntities' is not assignable to type 'keyof TEntities'. Two different types with this name exist, but they are unrelated.
          Type 'string | number | symbol' is not assignable to type 'keyof TEntities'.
            Type 'string' is not assignable to type 'keyof TEntities'.ts(2345)

I was able to solve it by casting like so:

const [, setSomethingMutation] = useMutation(
    (
      (somethingId: string) => setSomething({ id: somethingId })
    ) as MutationQueryConfigFactory<unknown>
  );

but that seems not so great to do.

TS version - 3.7.5
redux-query version - 3.3.1
redux-query-react version - 3.3.1

Hopefully all the issues with typescript are now closed. Will be closing this issue now that 3.4.2 is released.