Skip to content

Commit fe6bfa7

Browse files
meeroslavalex-okrushko
authored andcommitted
fix(store): replace Creator with ActionCreator on createAction (#2299)
* fix(store): replace insufficient type Creator with TypedCreator createAction returns incorrect type as neither Creator not it's return type contains `type`. Proper return type is ActionCreator with inner typed creator Closes meeroslav/ng-helpers#2 * fix(store): revert TypedCreator in favor of upcoming NotAllowedCheck
1 parent 98b74ad commit fe6bfa7

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

modules/store/src/action_creator.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ export function createAction<
100100
export function createAction<T extends string, C extends Creator>(
101101
type: T,
102102
config?: { _as: 'props' } | C
103-
): Creator {
103+
): ActionCreator<T> {
104104
if (typeof config === 'function') {
105105
return defineType(type, (...args: any[]) => ({
106106
...config(...args),
@@ -133,7 +133,10 @@ export function union<
133133
return undefined!;
134134
}
135135

136-
function defineType(type: string, creator: Creator): Creator {
136+
function defineType<T extends string>(
137+
type: T,
138+
creator: Creator
139+
): ActionCreator<T> {
137140
return Object.defineProperty(creator, 'type', {
138141
value: type,
139142
writable: false,

0 commit comments

Comments
 (0)