type UserData = {
accessToken: string;
id: number;
ldap: string;
roles: [];
tokenType: string;
};
type LoginState = {
loading: 'idle' | 'pending' | 'succeeded' | 'failed';
data: UserData[];
};
const initialState: LoginState = {
loading: 'idle',
data: [],
};
const userSlice = createSlice({
name: 'user',
initialState,
reducers: {},
extraReducers: builder => {
builder
.addCase(authUser.pending, state => {
state.loading = 'pending';
})
.addCase(authUser.fulfilled, (state, action) => {
state.loading = 'succeeded';
state.data.push(action.payload);
})
.addCase(authUser.rejected, state => {
state.loading = 'failed';
});
},
});
I am getting a TS error on this line -
state.data.push(action.payload)
This is the error that I am getting -
Not sure what I am missing. I am relatively new to TS.