diff --git a/modules/store/src/action_creator.ts b/modules/store/src/action_creator.ts index ac04889361..492fbedf8d 100644 --- a/modules/store/src/action_creator.ts +++ b/modules/store/src/action_creator.ts @@ -4,6 +4,7 @@ import { TypedAction, FunctionWithParametersType, NotAllowedCheck, + Props, } from './models'; // Action creators taken from ts-action library and modified a bit to better @@ -14,7 +15,7 @@ export function createAction( ): ActionCreator TypedAction>; export function createAction( type: T, - config: { _as: 'props'; _p: P } + config: Props

): ActionCreator) => P & TypedAction>; export function createAction< T extends string, @@ -120,7 +121,7 @@ export function createAction( } } -export function props

(): { _as: 'props'; _p: P } { +export function props

(): Props

{ return { _as: 'props', _p: undefined! }; } diff --git a/modules/store/src/models.ts b/modules/store/src/models.ts index ce1a2f2b4c..e6b56a872f 100644 --- a/modules/store/src/models.ts +++ b/modules/store/src/models.ts @@ -57,10 +57,6 @@ export const arraysAreNotAllowedMsg = 'arrays are not allowed in action creators'; type ArraysAreNotAllowed = typeof arraysAreNotAllowedMsg; -export type DisallowArraysAndTypeProperty = T extends any[] - ? ArraysAreNotAllowed - : T extends { type: any } ? TypePropertyIsNotAllowed : T; - export const typePropertyIsNotAllowedMsg = 'type property is not allowed in action creators'; type TypePropertyIsNotAllowed = typeof typePropertyIsNotAllowedMsg; @@ -89,6 +85,11 @@ export type ActionCreator< C extends Creator = Creator > = C & TypedAction; +export interface Props { + _as: 'props'; + _p: T; +} + export type FunctionWithParametersType

= ( ...args: P ) => R;