I'm trynig to implement authentifiaction slice in redux toolkit with typescript, but typescript is complaining about rejectWithValue error type and the action payload, please note that i'm using Axios and that i'm following the documentation but still complaining this my code
import { createAsyncThunk } from '@reduxjs/toolkit';
import { axiosClient } from 'src/network/api-client';
import {AxiosError} from 'axios'
type RegisterPayload = {
login: string;
password: string;
client: string;
first_name: string;
last_name: string;
patronymic: string;
date_of_birth: string;
};
export type User = {
token: string;
refresh_token: string;
};
type KnownError = {
errorMessage : string;
}
export const registerUser = createAsyncThunk<
{ token: string },
RegisterPayload,
{ rejectValue: KnownError }
>(
'users/register',
async (
{
login,
password,
client,
first_name,
last_name,
patronymic,
date_of_birth,
}, // these are the lines that triggers the first error
{rejectWithValue}
) => {
try {
const response = await axiosClient.post<User>('registration', {
login,
password,
client,
first_name,
last_name,
patronymic,
date_of_birth,
});
if (response.status === 201) {
localStorage.setItem('refresh', response.data.refresh_token);
return {
...response,
token: response.data.token,
};
}
} catch (err) {
const error: AxiosError<KnownError> = err; // this os the lines
that triggers the second error 'error' is underlined
if (!error.response) {
throw err;
}
return rejectWithValue(error.response.data);
}
);
and i'm having these errors


