You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
const{ useGetPokemonByNameQuery }=pokemonApi;// Wrapper to demonstrate the issueexportconstuseGetPokemonByNameQueryWrapper=(
...parameters: Parameters<typeofuseGetPokemonByNameQuery>)=>{returnuseGetPokemonByNameQuery(...parameters);};constuseTest=()=>{// data1 has type Pokemon | undefined as expectedconst{data: data1}=useGetPokemonByNameQuery("pikachu");// data2 has type any???const{data: data2}=useGetPokemonByNameQueryWrapper("pikachu");};
🙁 Actual behavior
When I wrap any query hook generated by Redux Toolkit Query with any simple wrapper function the return type stops being inferred and changes to 'any'. Check the example in the attached Sandbox in file /src/services/pokemon.ts
🙂 Expected behavior
I expect the wrapper function to preserve the return type of the wrapped function and to correctly infer it.
Additional information about the issue
No response
The text was updated successfully, but these errors were encountered:
🔎 Search Terms
ReturnType changes to any, wrapper function losing inferred types
🕗 Version & Regression Information
⏄1�7 Playground Link
https://codesandbox.io/p/devbox/lingering-fog-5fhtrv
💻 Code
🙁 Actual behavior
When I wrap any query hook generated by Redux Toolkit Query with any simple wrapper function the return type stops being inferred and changes to 'any'. Check the example in the attached Sandbox in file
/src/services/pokemon.ts🙂 Expected behavior
I expect the wrapper function to preserve the return type of the wrapped function and to correctly infer it.
Additional information about the issue
No response
The text was updated successfully, but these errors were encountered: