store.ts
export const store = configureStore({
    reducer: {
        auth: authReducer
    },
    middleware: [],
});
export type AppDispatch = typeof store.dispatch;
export type RootState = ReturnType<typeof store.getState>;
hooks.ts
export const useAppDispatch = () => useDispatch<AppDispatch>();
export const useAppSelector: TypedUseSelectorHook<RootState> = useSelector;
authSlice.ts (function that causes the problem)
export const fetchUser = createAsyncThunk(
    'users/fetchByTok',
    async () => {
        const res = await getUser();
        return res.data;
    }
)
Auth.ts
const Auth = ({ component, isLogged }: {component: any, isLogged: boolean}) => {
    const dispatch = useAppDispatch();
    
    useEffect(() => {
        dispatch(fetchUser()) // <----------- ERROR
    }, []);
    return isLogged ? component : <Navigate to='/sign-in' replace={true} />;
}
export default Auth;
I have a createAsyncThunk function that fetches the user, but I cannot actually put it in the dispatch()...
- Argument of type 'AsyncThunkAction<any, void, {}>' is not assignable to parameter of type 'AnyAction'.
- Property 'type' is missing in type 'AsyncThunkAction<any, void, {}>' but required in type 'AnyAction'.ts(2345)
First time using this, so a nice explanation would be nice :).
 
     
     
     
     
     
     
     
     
     
     
     
    