From 7ed56c88f1952fba53c853d6baa20fbe874f0c37 Mon Sep 17 00:00:00 2001 From: aokrushko Date: Mon, 6 Jan 2020 20:05:19 -0500 Subject: [PATCH] Remove DisallowArraysAndTypeProperty and create Props --- modules/store/src/action_creator.ts | 5 +++-- modules/store/src/models.ts | 9 +++++---- 2 files changed, 8 insertions(+), 6 deletions(-) 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;