Skip to content

Commit

Permalink
feat(types): Generalized .d.ts typedef (#67)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrnkr authored and kevinvangelder committed Apr 9, 2019
1 parent d1b6e39 commit a552b6b
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions index.d.ts
@@ -1,20 +1,20 @@
declare module 'reduxsauce' {
import { AnyAction, Reducer } from 'redux';
import { Action, AnyAction, Reducer } from 'redux';

export interface Actions {
[action: string]: string[] | null;
}

export interface ActionTypes {
export interface DefaultActionTypes {
[action: string]: string;
}

export interface ActionCreators {
export interface DefaultActionCreators {
[action: string]: (...args: any[]) => AnyAction;
}

export interface Handlers<S> {
[type: string]: (state: S, action: AnyAction) => S;
export interface Handlers<S, A = AnyAction> {
[type: string]: (state: S, action: A) => S;
}

/**
Expand All @@ -26,20 +26,20 @@ declare module 'reduxsauce' {
prefix: string;
}

interface CreatedActions {
Types: ActionTypes;
Creators: ActionCreators;
export interface CreatedActions<T = DefaultActionTypes, C = DefaultActionCreators> {
Types: T;
Creators: C;
}

export function createActions(
export function createActions<T = DefaultActionTypes, C = DefaultActionCreators>(
actions: Actions,
options?: Options
): CreatedActions;
): CreatedActions<T, C>;

export function createReducer<S>(
export function createReducer<S = {}, A extends Action = AnyAction>(
initialState: S,
handlers: Handlers<S>
): Reducer<S>;
handlers: Handlers<S, A>
): Reducer<S, A>;

export function createTypes(types: string, options?: Options): ActionTypes;
export function createTypes<T = DefaultActionTypes>(types: string, options?: Options): T;
}

0 comments on commit a552b6b

Please sign in to comment.