amplitude / redux-query

A library for managing network state in Redux
https://amplitude.github.io/redux-query
Other
1.1k stars 67 forks source link

update hook Typescript types #204

Closed ricfang closed 4 years ago

ricfang commented 4 years ago

hey @siegcollado I noticed you changed (https://github.com/amplitude/redux-query/pull/176/files#diff-c7534d134a79c61c9c2a387721a367c692d97f2e18421782c58ae2f853a6d590R48-R50)

export type RunMutation<TEntities> = <TEntities>(
    ...args: any    
  ) => Promise<ActionPromiseValue<TEntities>>;

to

 export type ActionPromise<TEntities = Entities> =
    | Promise<ActionPromiseValue<TEntities>>
    | undefined;
  type RunMutation<TEntities = Entities, TArgs = never> = (
    ...args: TArgs
  ) => ActionPromise<TEntities>;

based on https://github.com/amplitude/redux-query/blob/master/packages/redux-query-react/src/hooks/use-mutation.js#L13-L15, I think the return type should be what was there before (never returning undefined)

do you have any more context on that change?

rctbusk commented 4 years ago

@ManThursday I agree this is not backwards compatible. @ricfang can we add back the ActionPromise for now? Just have the export so that we don't break. Will make the upgrade a minor version release. I will remove the type in the next major release. (which hopefully will be soon).

ricfang commented 4 years ago

@rctbusk added back the export and removed undefined