From 9c16e2c293a7039e4b556472de958d5dfebce870 Mon Sep 17 00:00:00 2001 From: jasonhodges Date: Tue, 4 Jun 2019 17:01:19 -0600 Subject: [PATCH] refactor(selectors) Capture the type of a selectors projector - supply a default projector type to MemoizedSelector --- modules/store/src/selector.ts | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/modules/store/src/selector.ts b/modules/store/src/selector.ts index fb6128a08e..3600cd78a9 100644 --- a/modules/store/src/selector.ts +++ b/modules/store/src/selector.ts @@ -12,17 +12,26 @@ export type MemoizeFn = (t: AnyFn) => MemoizedProjection; export type ComparatorFn = (a: any, b: any) => boolean; -export interface MemoizedSelector - extends Selector { +export type DefaultProjectorFn = (...args: any[]) => T; + +export interface MemoizedSelector< + State, + Result, + ProjectorFn = DefaultProjectorFn +> extends Selector { release(): void; - projector: AnyFn; + projector: ProjectorFn; setResult: (result?: Result) => void; } -export interface MemoizedSelectorWithProps - extends SelectorWithProps { +export interface MemoizedSelectorWithProps< + State, + Props, + Result, + ProjectorFn = DefaultProjectorFn +> extends SelectorWithProps { release(): void; - projector: AnyFn; + projector: ProjectorFn; setResult: (result?: Result) => void; }