UNPKG

3.07 kBMarkdownView Raw
1# Installation
2> `npm install --save @types/redux-logger`
3
4# Summary
5This package contains type definitions for redux-logger (https://github.com/theaqua/redux-logger).
6
7# Details
8Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/redux-logger.
9## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/redux-logger/index.d.ts)
10````ts
11// Type definitions for redux-logger 3.0
12// Project: https://github.com/theaqua/redux-logger
13// Definitions by: Alexander Rusakov <https://github.com/arusakov>
14// Kevin Groat <https://github.com/kgroat>
15// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
16
17export as namespace ReduxLogger;
18
19import * as Redux from 'redux';
20
21export const logger: Redux.Middleware;
22
23export type LoggerPredicate = (
24 getState: () => any,
25 action: any,
26 logEntry?: LogEntryObject
27) => boolean;
28
29export type StateToString = (state: any) => string;
30export type ActionToString = (action: any) => string;
31export type ErrorToString = (error: any, prevState: any) => string;
32
33export interface ColorsObject {
34 title?: boolean | ActionToString | undefined;
35 prevState?: boolean | StateToString | undefined;
36 action?: boolean | ActionToString | undefined;
37 nextState?: boolean | StateToString | undefined;
38 error?: boolean | ErrorToString | undefined;
39}
40
41export interface LevelObject {
42 prevState?: string | boolean | StateToString | undefined;
43 action?: string | boolean | ActionToString | undefined;
44 nextState?: string | boolean | StateToString | undefined;
45 error?: string | boolean | ErrorToString | undefined;
46}
47
48export interface LogEntryObject {
49 action?: string | boolean | ActionToString | undefined;
50 started?: number | undefined;
51 startedTime?: Date | undefined;
52 took?: number | undefined;
53 error?(error: any): any;
54 nextState?(state: any): any;
55 prevState?(state: any): any;
56}
57
58export interface ReduxLoggerOptions {
59 level?: string | ActionToString | LevelObject | undefined;
60 duration?: boolean | undefined;
61 timestamp?: boolean | undefined;
62 colors?: ColorsObject | false | undefined;
63 titleFormatter?(formattedAction: any, formattedTime: string, took: number): string;
64 logger?: any;
65 logErrors?: boolean | undefined;
66 collapsed?: boolean | LoggerPredicate | undefined;
67 predicate?: LoggerPredicate | undefined;
68 diff?: boolean | undefined;
69 diffPredicate?: LoggerPredicate | undefined;
70 stateTransformer?(state: any): any;
71 actionTransformer?(action: any): any;
72 errorTransformer?(error: any): any;
73}
74
75export function createLogger(options?: ReduxLoggerOptions): Redux.Middleware;
76
77export default logger;
78
79````
80
81### Additional Details
82 * Last updated: Wed, 07 Jul 2021 18:31:54 GMT
83 * Dependencies: [@types/redux](https://npmjs.com/package/@types/redux)
84 * Global values: `ReduxLogger`
85
86# Credits
87These definitions were written by [Alexander Rusakov](https://github.com/arusakov), and [Kevin Groat](https://github.com/kgroat).
88
\No newline at end of file