UNPKG

3.5 kBTypeScriptView Raw
1declare module 'react-hot-loader' {
2 import * as React from 'react'
3
4 interface ErrorReporterProps {
5 error: any
6 }
7
8 export interface AppContainerProps {
9 children?: React.ReactElement<any>
10 errorReporter?:
11 | React.ComponentClass<ErrorReporterProps>
12 | React.StatelessComponent<ErrorReporterProps>
13 }
14
15 export class AppContainer extends React.Component<
16 AppContainerProps,
17 React.ComponentState
18 > {}
19
20 /**
21 * Marks module and a returns a HOC to mark a Component inside it as hot-exported
22 * @param {NodeModuleObject} module ALWAYS should be just "module".
23 * @return {function} "hot" HOC.
24 *
25 * @example marks current module as hot, and export MyComponent as HotExportedMyComponent
26 * export default hot(module)(MyComponent)
27 */
28 export function hot(
29 module: any,
30 ): <T = React.ComponentType<any>>(Component: T) => T
31
32 /**
33 * Marks component as `cold`, and making it invisible for React-Hot-Loader.
34 * Any changes to that component will cause local state loss.
35 * @param {React.ComponentType} component to chill
36 * @return {React.ComponentType} component, as it was passed in.
37 *
38 * @example marks some component as cold
39 * export default cold(MyComponent)
40 */
41 export function cold<T = React.ComponentType<any>>(component: T): T
42
43 /**
44 * Tests are types of two components equal
45 * @param {Component} typeA
46 * @param {Component} typeB
47 * @return {boolean} are they equal
48 *
49 * @example test that some rendered component(ReactElement), has the same type as BaseComponent
50 * areComponentEqual(RenderedComponent.type, BaseComponent)
51 */
52 export function areComponentsEqual<T>(
53 typeA: React.ComponentType<T>,
54 typeB: React.ComponentType<T>,
55 ): boolean
56
57 export interface Config {
58 /**
59 * Specify loglLevel, default to 'error', set it to false to disable logs.
60 * Available levels: ['debug', 'log', 'warn', 'error']
61 */
62 logLevel: string
63
64 /**
65 *
66 * @param {any} type being registered. This could be ANY top level variable among project.
67 * @param {string} uniqueLocalName - variable name
68 * @param {string} fileName - origin file
69 * @return {any}
70 */
71 onComponentRegister: (
72 type: any,
73 uniqueLocalName: string,
74 fileName: string,
75 ) => any
76
77 /**
78 *
79 * @param type {any} type being rendered. The first argument of React.createElement
80 * @param displayName {string} type display name (if exists)
81 */
82 onComponentCreate: (type: any, displayName: string) => any
83
84 /**
85 * Allows using SFC without changes. leading to some components not updated
86 */
87 pureSFC: boolean
88
89 /**
90 * keep render method unpatched, moving sideEffect to componentDidUpdate
91 */
92 pureRender: boolean
93
94 /**
95 * Allows SFC to be used, enables "intermediate" components used by Relay, should be disabled for Preact
96 */
97 allowSFC: boolean
98
99 /**
100 * Disable "hot-replacement-render"
101 */
102 disableHotRenderer: boolean
103
104 /**
105 * Disable "hot-replacement-render" when injection into react-dom are made
106 */
107 disableHotRendererWhenInjected: boolean
108
109 /**
110 * flag to completely disable RHL for SFC
111 */
112 ignoreSFC: boolean
113
114 /**
115 * flag to completely disable RHL for Components
116 */
117 ignoreComponents: boolean
118 }
119 /**
120 * Confugures how React Hot Loader works
121 * @param {Config} config
122 */
123 export function setConfig(config: Partial<Config>): void
124}
125
\No newline at end of file