Looking to revise the TypeScript syntax of a lesson found at this link.
I am aiming to extract a specific type from a union type using the following syntax:
Actions['type'][ActionTypes.FEED_CREATE_POST]
The available action types are defined as:
type Actions = IActionWithPayload<ActionTypes.FEED_CREATE_POST, {
text: string;
files: any;
}> | IActionWithPayload<ActionTypes.FEED_GET_NEWS, {
loadMore: boolean;
}>
Regarding the 'type' property:
(property) type: ActionTypes.FEED_GET_NEWS | ActionTypes.FEED_CREATE_POST
An issue arises with the message stating:
Property 'FEED_CREATE_POST' does not exist on type 'ActionTypes.FEED_GET_NEWS | ActionTypes.FEED_CREATE_POST'.
What is causing this error and how can it be resolved? Using TypeScript version 3.1.3.