File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed
Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -43,13 +43,21 @@ describe('createAction()', () => {
4343 ) ;
4444 } ) ;
4545
46- it ( 'should not allow ararys ' , ( ) => {
46+ it ( 'should not allow arrays ' , ( ) => {
4747 expectSnippet ( `
4848 const foo = createAction('FOO', props<[]>());
4949 ` ) . toFail (
5050 / T y p e ' P r o p s < \[ \] > ' i s n o t a s s i g n a b l e t o t y p e ' " a r r a y s a r e n o t a l l o w e d i n a c t i o n c r e a t o r s " ' /
5151 ) ;
5252 } ) ;
53+
54+ it ( 'should not allow empty objects' , ( ) => {
55+ expectSnippet ( `
56+ const foo = createAction('FOO', props<{}>());
57+ ` ) . toFail (
58+ / T y p e ' P r o p s < \{ \} > ' i s n o t a s s i g n a b l e t o t y p e ' " e m p t y o b j e c t s a r e n o t a l l o w e d i n a c t i o n c r e a t o r s " ' /
59+ ) ;
60+ } ) ;
5361 } ) ;
5462
5563 describe ( 'with function' , ( ) => {
Original file line number Diff line number Diff line change @@ -61,6 +61,10 @@ export const typePropertyIsNotAllowedMsg =
6161 'type property is not allowed in action creators' ;
6262type TypePropertyIsNotAllowed = typeof typePropertyIsNotAllowedMsg ;
6363
64+ export const emptyObjectsAreNotAllowedMsg =
65+ 'empty objects are not allowed in action creators' ;
66+ type EmptyObjectsAreNotAllowed = typeof emptyObjectsAreNotAllowedMsg ;
67+
6468export type FunctionIsNotAllowed <
6569 T ,
6670 ErrorMessage extends string
@@ -77,6 +81,8 @@ export type NotAllowedCheck<T extends object> = T extends any[]
7781 ? ArraysAreNotAllowed
7882 : T extends { type : any }
7983 ? TypePropertyIsNotAllowed
84+ : keyof T extends never
85+ ? EmptyObjectsAreNotAllowed
8086 : unknown ;
8187
8288/**
You can’t perform that action at this time.
0 commit comments