From 4e39cc1ce571eed32f90f9cc1a9e706764c8131f Mon Sep 17 00:00:00 2001 From: Jason Hodges Date: Wed, 5 Jun 2019 21:51:24 -0600 Subject: [PATCH] feat(store): capture the type of a selector projector function (#1920) Closes #1908 --- 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; }