Skip to content

Commit 4e39cc1

Browse files
jasonhodgesbrandonroberts
authored andcommitted
feat(store): capture the type of a selector projector function (#1920)
Closes #1908
1 parent d81ddeb commit 4e39cc1

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

modules/store/src/selector.ts

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,26 @@ export type MemoizeFn = (t: AnyFn) => MemoizedProjection;
1212

1313
export type ComparatorFn = (a: any, b: any) => boolean;
1414

15-
export interface MemoizedSelector<State, Result>
16-
extends Selector<State, Result> {
15+
export type DefaultProjectorFn<T> = (...args: any[]) => T;
16+
17+
export interface MemoizedSelector<
18+
State,
19+
Result,
20+
ProjectorFn = DefaultProjectorFn<Result>
21+
> extends Selector<State, Result> {
1722
release(): void;
18-
projector: AnyFn;
23+
projector: ProjectorFn;
1924
setResult: (result?: Result) => void;
2025
}
2126

22-
export interface MemoizedSelectorWithProps<State, Props, Result>
23-
extends SelectorWithProps<State, Props, Result> {
27+
export interface MemoizedSelectorWithProps<
28+
State,
29+
Props,
30+
Result,
31+
ProjectorFn = DefaultProjectorFn<Result>
32+
> extends SelectorWithProps<State, Props, Result> {
2433
release(): void;
25-
projector: AnyFn;
34+
projector: ProjectorFn;
2635
setResult: (result?: Result) => void;
2736
}
2837

0 commit comments

Comments
 (0)