diff --git a/modules/store/spec/action_creator.spec.ts b/modules/store/spec/action_creator.spec.ts index bf95e8087b..826ab35572 100644 --- a/modules/store/spec/action_creator.spec.ts +++ b/modules/store/spec/action_creator.spec.ts @@ -77,11 +77,20 @@ describe('Action Creators', () => { const value = fooAction.bar; `).toFail(/'bar' does not exist on type/); }); + it('should not allow type property', () => { expectSnippet(` const foo = createAction('FOO', (type: string) => ({type})); `).toFail( - /Type '{ type: string; }' is not assignable to type '"type property is not allowed in action creators"/ + /Type '{ type: string; }' is not assignable to type '"type property is not allowed in action creators"'/ + ); + }); + + it('should not allow ararys', () => { + expectSnippet(` + const foo = createAction('FOO', () => [ ]); + `).toFail( + /Type 'any\[]' is not assignable to type '"arrays are not allowed in action creators"'/ ); }); }); @@ -150,12 +159,19 @@ describe('Action Creators', () => { }); it('should not allow type property', () => { - const foo = createAction('FOO', props<{ type: number }>() as any); expectSnippet(` const foo = createAction('FOO', props<{ type: number }>()); `).toFail( /Argument of type '"type property is not allowed in action creators"' is not assignable to parameter of type/ ); }); + + it('should not allow ararys', () => { + expectSnippet(` + const foo = createAction('FOO', props<[]>()); + `).toFail( + /Argument of type '"arrays are not allowed in action creators"' is not assignable to parameter of type/ + ); + }); }); }); diff --git a/modules/store/src/action_creator.ts b/modules/store/src/action_creator.ts index e2cc6ecc78..3882eba322 100644 --- a/modules/store/src/action_creator.ts +++ b/modules/store/src/action_creator.ts @@ -4,7 +4,7 @@ import { TypedAction, FunctionWithParametersType, PropsReturnType, - DisallowTypeProperty, + DisallowArraysAndTypeProperty, } from './models'; // Action creators taken from ts-action library and modified a bit to better @@ -23,7 +23,7 @@ export function createAction< R extends object >( type: T, - creator: Creator
> + creator: Creator
> ): FunctionWithParametersType
> & TypedAction ;
-
-export type PropsReturnType ;
+
+export type PropsReturnType