I am struggling to comprehend the reason behind this error message.
Property 'message' does not exist on type '{ username: string; } | { message: string; }'.
The following is a snippet of the relevant code:
// types.ts
type LoginMessage = {
type: 'login';
payload: { username: string };
};
type SendChatMessage = {
type: 'send_chat_message';
payload: { message: string };
};
export type ClientToServerMessage = LoginMessage | SendChatMessage;
// reducer.js
const { message } = action.payload; // this specific line is causing the issue
// action is of type ClientToServerMessage