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