Closed ShravanSunder closed 4 years ago
I just tested this in a codesandbox (see https://codesandbox.io/s/eloquent-keller-vp85m?file=/src/App.tsx ) and it seems to be working correct for me. Can you provide a reproduction of this?
Also, in general once you start using thunkApi.getState()
usually you need to provide generic arguments as described in the documentation:
https://redux-toolkit.js.org/usage/usage-with-typescript#createasyncthunk
Also, are you using WebStorm? We've had another case where in WebStorm, incorrect types were shown because they try to speed up things with an incorrect algorithm.
i'm not using webstorm. Its a react app hosted in asp.NET. part of the app is in plain js. And some of it is in typescript.
I"ve been converting it to typescript as i go.
I tried recreating this in codesandbox and it seems to work fine. i'm trying to think of how i could send a reproduction other wise
oh once i added the generic arguments it worked!
const getStore = createAsyncThunk<any, getStoreType, any>(
thanks so much for the pointer! @phryneas
I have the following thunk action
however when i add the condition the type changes to
The issue is with the <unknown, void, {}> versus <any, {storeGuid: string;}, {}> i can't currently use the thunk properly in my component as typescript complains about the function used with a parameter when none is expected.
I'm not sure how to force the thunk type to retain my typing
> TS2554: Expected 0 arguments, but got 1.