UNPKG

1.71 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
8type LoggerPredicate = (getState: () => any, action: any) => boolean;
9
10type StateToString = (state: any) => string;
11type ActionToString = (action: any) => string;
12type ErrorToString = (error: any, prevState: any) => string;
13
14interface ColorsObject {
15 title?: boolean | ActionToString;
16 prevState?: boolean | StateToString;
17 action?: boolean | ActionToString;
18 nextState?: boolean | StateToString;
19 error?: boolean | ErrorToString;
20}
21
22interface LevelObject {
23 prevState?: string | boolean | StateToString;
24 action?: string | boolean | ActionToString;
25 nextState?: string | boolean | StateToString;
26 error?: string | boolean | ErrorToString;
27}
28
29interface ReduxLoggerOptions {
30 level?: string | ActionToString | LevelObject;
31 duration?: boolean;
32 timestamp?: boolean;
33 colors?: ColorsObject;
34 logger?: any;
35 logErrors?: boolean;
36 collapsed?: boolean | LoggerPredicate;
37 predicate?: LoggerPredicate;
38 stateTransformer?: (state: any) => any;
39 actionTransformer?: (action: any) => any;
40 errorTransformer?: (error: any) => any;
41 diff?: boolean;
42 diffPredicate?: LoggerPredicate;
43}
44
45
46// Trickery to get TypeScript to accept that our anonymous, non-default export is a function.
47// see https://github.com/Microsoft/TypeScript/issues/3612 for more
48declare namespace createLogger { }
49declare function createLogger(options?: ReduxLoggerOptions): Redux.Middleware;
50export = createLogger;