UNPKG

1.83 kBTypeScriptView Raw
1// Type definitions for redux-logger v2.6.0
2// Project: https://github.com/fcomb/redux-logger
3// Definitions by: Alexander Rusakov <https://github.com/arusakov/>
4// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
5
6import * as Redux from "redux";
7
8// Trickery to get TypeScript to accept that our anonymous, non-default export is a function.
9// see https://github.com/Microsoft/TypeScript/issues/3612 for more
10declare namespace createLogger {
11 export type LoggerPredicate = (getState: () => any, action: any) => boolean;
12
13 export type StateToString = (state: any) => string;
14 export type ActionToString = (action: any) => string;
15 export type ErrorToString = (error: any, prevState: any) => string;
16
17 export interface ColorsObject {
18 title?: boolean | ActionToString;
19 prevState?: boolean | StateToString;
20 action?: boolean | ActionToString;
21 nextState?: boolean | StateToString;
22 error?: boolean | ErrorToString;
23 }
24
25 export interface LevelObject {
26 prevState?: string | boolean | StateToString;
27 action?: string | boolean | ActionToString;
28 nextState?: string | boolean | StateToString;
29 error?: string | boolean | ErrorToString;
30 }
31
32 export interface ReduxLoggerOptions {
33 level?: string | ActionToString | LevelObject;
34 duration?: boolean;
35 timestamp?: boolean;
36 colors?: ColorsObject;
37 logger?: any;
38 logErrors?: boolean;
39 collapsed?: boolean | LoggerPredicate;
40 predicate?: LoggerPredicate;
41 stateTransformer?: (state: any) => any;
42 actionTransformer?: (action: any) => any;
43 errorTransformer?: (error: any) => any;
44 diff?: boolean;
45 diffPredicate?: LoggerPredicate;
46 }
47}
48declare function createLogger(options?: createLogger.ReduxLoggerOptions): Redux.Middleware;
49export = createLogger;