Skip to content

Commit

Permalink
Reorder typings declaration file
Browse files Browse the repository at this point in the history
  • Loading branch information
toomuchdesign committed Jan 30, 2019
1 parent aec5e31 commit e754fb7
Showing 1 changed file with 46 additions and 35 deletions.
81 changes: 46 additions & 35 deletions src/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,35 @@
import {createSelector} from 'reselect';

export type Selector<S, R> = (state: S) => R;
export type ParametricSelector<S, P, R> = (
state: S,
props: P,
...args: any[]
) => R;

export type Resolver<S> = (state: S, ...args: any[]) => any;
export type ParametricResolver<S, P> = (
state: S,
props: P,
...args: any[]
) => any;

export type OutputSelector<S, R, C, D> = Selector<S, R> & {
resultFunc: C;
dependencies: D;
recomputations: () => number;
resetRecomputations: () => number;
};
export type OutputParametricSelector<S, P, R, C, D> = ParametricSelector<
S,
P,
R
> & {
resultFunc: C;
dependencies: D;
recomputations: () => number;
resetRecomputations: () => number;
};

export type CreateSelectorInstance = typeof createSelector;

Expand All @@ -17,13 +44,6 @@ type Options =
}
| CreateSelectorInstance;

export type OutputSelector<S, R, C, D> = Selector<S, R> & {
resultFunc: C;
dependencies: D;
recomputations: () => number;
resetRecomputations: () => number;
};

export type OutputCachedSelector<S, R, C, D> = (
resolver: Resolver<S>,
optionsOrSelectorCreator?: Options
Expand All @@ -34,29 +54,6 @@ export type OutputCachedSelector<S, R, C, D> = (
cache: ICacheObject;
};

export type ParametricSelector<S, P, R> = (
state: S,
props: P,
...args: any[]
) => R;

export type ParametricResolver<S, P> = (
state: S,
props: P,
...args: any[]
) => any;

export type OutputParametricSelector<S, P, R, C, D> = ParametricSelector<
S,
P,
R
> & {
resultFunc: C;
dependencies: D;
recomputations: () => number;
resetRecomputations: () => number;
};

export type OutputParametricCachedSelector<S, P, R, C, D> = (
resolver: ParametricResolver<S, P>,
optionsOrSelectorCreator?: Options
Expand All @@ -71,6 +68,10 @@ export type OutputParametricCachedSelector<S, P, R, C, D> = (
cache: ICacheObject;
};

/*
* Homogeneous selectors, parameter types
*/

/* one selector */
export default function createCachedSelector<S, R1, T>(
selector: Selector<S, R1>,
Expand Down Expand Up @@ -993,7 +994,9 @@ export default function createCachedSelector<
]
>;

/* array argument */
/*
* Homogeneous selectors, array argument
*/

/* one selector */
export default function createCachedSelector<S, R1, T>(
Expand Down Expand Up @@ -1951,7 +1954,9 @@ export default function createCachedSelector<
]
>;

/* heterogeneous selector parameter types */
/*
* Heterogeneous selectors, parameter types
*/

/* one selector */
export default function createCachedSelector<S1, R1, T>(
Expand Down Expand Up @@ -3126,7 +3131,9 @@ export default function createCachedSelector<
]
>;

/* array argument */
/*
* Heterogeneous selectors, array argument
*/

/* one selector */
export default function createCachedSelector<S1, R1, T>(
Expand Down Expand Up @@ -4336,8 +4343,9 @@ export default function createCachedSelector<
]
>;

/* any number of uniform selectors */

/*
* Any number of uniform selectors
*/
export default function createCachedSelector<S, R, T>(
selectors: Selector<S, R>[],
combiner: (...res: R[]) => T
Expand All @@ -4353,6 +4361,9 @@ export default function createCachedSelector<S, P, R, T>(
ParametricSelector<S, P, R>[]
>;

/*
* Cache objects
*/
export interface ICacheObject {
set(key: any, selectorFn: any): void;
get(key: any): any;
Expand Down

0 comments on commit e754fb7

Please sign in to comment.