Lately, I have been delving into the redux-toolkit
library but I am struggling with understanding the type declaration of the createAction
function as demonstrated below.
The createAction
function returns a PayloadActionCreator which includes a generic of
<ReturnType<PA>['payload'], T, PA>
. Could someone explain what is meant by ReturnType<PA>['payload']
?
export declare function createAction<PA extends PrepareAction<any>, T extends string = string>(type: T, prepareAction: PA): PayloadActionCreator<ReturnType<PA>['payload'], T, PA>