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()', () => {
43
43
) ;
44
44
} ) ;
45
45
46
- it ( 'should not allow ararys ' , ( ) => {
46
+ it ( 'should not allow arrays ' , ( ) => {
47
47
expectSnippet ( `
48
48
const foo = createAction('FOO', props<[]>());
49
49
` ) . toFail (
50
50
/ 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 " ' /
51
51
) ;
52
52
} ) ;
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
+ } ) ;
53
61
} ) ;
54
62
55
63
describe ( 'with function' , ( ) => {
Original file line number Diff line number Diff line change @@ -61,6 +61,10 @@ export const typePropertyIsNotAllowedMsg =
61
61
'type property is not allowed in action creators' ;
62
62
type TypePropertyIsNotAllowed = typeof typePropertyIsNotAllowedMsg ;
63
63
64
+ export const emptyObjectsAreNotAllowedMsg =
65
+ 'empty objects are not allowed in action creators' ;
66
+ type EmptyObjectsAreNotAllowed = typeof emptyObjectsAreNotAllowedMsg ;
67
+
64
68
export type FunctionIsNotAllowed <
65
69
T ,
66
70
ErrorMessage extends string
@@ -77,6 +81,8 @@ export type NotAllowedCheck<T extends object> = T extends any[]
77
81
? ArraysAreNotAllowed
78
82
: T extends { type : any }
79
83
? TypePropertyIsNotAllowed
84
+ : keyof T extends never
85
+ ? EmptyObjectsAreNotAllowed
80
86
: unknown ;
81
87
82
88
/**
You can’t perform that action at this time.
0 commit comments