// TypeScript Version: 2.9 /// rereducer type ReducerLikeFunction = (state: TS, action: TA, ...others: any[]) => TRet; export type Reducer = (state: TS, action: TA, ...others: any[]) => TS; type MatcherFunction = ReducerLikeFunction; type AdvancedRuleDef = [Matcher, Reducer]; type Matcher = string | MatcherFunction | MatcherArray; interface MatcherArray extends Array> { } type SelectWithType = TA extends { type: TAType } ? TA : never; interface ActionWithType { type: any; } interface ActionWithPayload

extends ActionWithType { payload: P; } export type ActionTypeRuleDef = TA extends { type: infer TAType } ? [TAType, Reducer>] : AdvancedRuleDef; export type RuleDef = | ActionTypeRuleDef | AdvancedRuleDef; declare function rereducer(initialValue: TS, ...ruleDefs: Array>): Reducer; export default rereducer; /// assocReducer type TemplateType = { [K in keyof TO]: TO[K] | ReducerLikeFunction }; export function assocReducer( keyGetter: ReducerLikeFunction, template: TemplateType | ReducerLikeFunction ): Reducer; /// subReducer /* Note: Reducer is of type `unknown | Reducer`, but as we don't have unknown because the test runner * doesn't support TS3.0 yet, we have to replace this for any, and `any | [...]` is `any`. */ type Getter = string | ReducerLikeFunction; export function subReducer(getters: Getter | Array>, reducer: any): Reducer; /// concatReducer export function concatReducer(getter: Reducer): Reducer; /// mergeReducer export function mergeReducer(reducer: Partial | ReducerLikeFunction>): Reducer; /// isType export function isType(x: TA['type']): MatcherFunction; /// payload export function payload(...path: string[]): ReducerLikeFunction, any>; /// getPayload export function getPayload(state: any, action: ActionWithPayload): TP;