Skip to content

Commit f6336d5

Browse files
timdeschryverbrandonroberts
authored andcommitted
fix(store): add not allowed check to action creator config (#2313)
1 parent 33241cb commit f6336d5

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

modules/store/spec/types/action_creator.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ describe('createAction()', () => {
3939
expectSnippet(`
4040
const foo = createAction('FOO', props<{ type: number }>());
4141
`).toFail(
42-
/Argument of type '"type property is not allowed in action creators"' is not assignable to parameter of type/
42+
/ Type 'Props<\{ type: number; \}>' is not assignable to type '"type property is not allowed in action creators"'/
4343
);
4444
});
4545

4646
it('should not allow ararys', () => {
4747
expectSnippet(`
4848
const foo = createAction('FOO', props<[]>());
4949
`).toFail(
50-
/Argument of type '"arrays are not allowed in action creators"' is not assignable to parameter of type/
50+
/Type 'Props<\[\]>' is not assignable to type '"arrays are not allowed in action creators"'/
5151
);
5252
});
5353
});
@@ -80,15 +80,15 @@ describe('createAction()', () => {
8080
expectSnippet(`
8181
const foo = createAction('FOO', (type: string) => ({type}));
8282
`).toFail(
83-
/Type '{ type: string; }' is not assignable to type '"type property is not allowed in action creators"'/
83+
/Type '\(type: string\) => \{ type: string; \}' is not assignable to type '"type property is not allowed in action creators"'/
8484
);
8585
});
8686

8787
it('should not allow arrays', () => {
8888
expectSnippet(`
8989
const foo = createAction('FOO', () => [ ]);
9090
`).toFail(
91-
/Type 'any\[]' is not assignable to type '"arrays are not allowed in action creators"'/
91+
/Type '\(\) => any\[\]' is not assignable to type '"arrays are not allowed in action creators"'/
9292
);
9393
});
9494
});

modules/store/spec/types/utils.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ export const compilerOptions = () => ({
22
moduleResolution: 'node',
33
target: 'es2015',
44
baseUrl: '.',
5+
experimentalDecorators: true,
56
paths: {
67
'@ngrx/store': ['./modules/store'],
78
},

modules/store/src/action_creator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export function createAction<T extends string>(
1515
): ActionCreator<T, () => TypedAction<T>>;
1616
export function createAction<T extends string, P extends object>(
1717
type: T,
18-
config: Props<P>
18+
config: Props<P> & NotAllowedCheck<P>
1919
): ActionCreator<T, (props: P & NotAllowedCheck<P>) => P & TypedAction<T>>;
2020
export function createAction<
2121
T extends string,

0 commit comments

Comments
 (0)