Answer the question
In order to leave comments, you need to log in
Argument like "never[] | undefined" cannot be assigned to a parameter of type "never".?
I just started learning TypeScript and I can't understand what he wants from me.
There is a certain store where user info is pushed, but TS gives an error
"Argument like "never[] | undefined" cannot be assigned to a parameter of type "never".
Type "undefined" cannot be assigned to type "never".ts(2345)"
interface IUser {
type: string;
payload: never[] | undefined;
}
const usersSlice = createSlice({
name: "user",
initialState: {
users: [],
},
reducers: {
users(state, action: IUser) {
state.users.push(action.payload);
},
},
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question