-
Notifications
You must be signed in to change notification settings - Fork 202
/
Copy pathtypes.d.ts
83 lines (69 loc) · 2.28 KB
/
types.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/// <reference types="react" />
declare namespace WhyDidYouRender {
interface HookDifference {
pathString: string;
diffType: string;
prevValue: any;
nextValue: any;
}
interface ReasonForUpdate {
hookDifferences: HookDifference[];
propsDifferences: boolean;
stateDifferences: boolean;
}
interface UpdateInfo {
Component: React.Component;
displayName: string;
prevProps: any;
prevState: any;
nextProps: any;
nextState: any;
prevHook: any;
nextHook: any;
reason: ReasonForUpdate;
options: WhyDidYouRenderOptions;
hookName?: string;
}
type ExtraHookToTrack = [any, string];
interface WhyDidYouRenderOptions {
include?: RegExp[];
exclude?: RegExp[];
trackHooks?: boolean;
trackExtraHooks?: Array<ExtraHookToTrack>;
logOnDifferentValues?: boolean;
hotReloadBufferMs?: number;
onlyLogs?: boolean;
collapseGroups?: boolean;
titleColor?: string;
diffNameColor?: string;
diffPathColor?: string;
notifier?: (options: UpdateInfo) => void;
}
type WhyDidYouRenderComponentMember = WhyDidYouRenderOptions|boolean
}
declare module '@welldone-software/why-did-you-render' {
export import ReasonForUpdate = WhyDidYouRender.ReasonForUpdate;
export import UpdateInfo = WhyDidYouRender.UpdateInfo;
export import WhyDidYouRenderOptions = WhyDidYouRender.WhyDidYouRenderOptions;
export import HookDifference = WhyDidYouRender.HookDifference;
export default function whyDidYouRender(react: typeof React, options?: WhyDidYouRenderOptions): typeof React;
}
declare namespace React {
interface FunctionComponent<P = {}> {
whyDidYouRender?: WhyDidYouRender.WhyDidYouRenderComponentMember;
}
interface ExoticComponent<P = {}> {
whyDidYouRender?: WhyDidYouRender.WhyDidYouRenderComponentMember;
}
namespace Component {
const whyDidYouRender: WhyDidYouRender.WhyDidYouRenderComponentMember;
}
/* not supported.
see https://github.com/microsoft/TypeScript/issues/33892
and https://github.com/microsoft/TypeScript/issues/34516
and https://github.com/microsoft/TypeScript/issues/32185
// interface Component<P = {}, S = {}, SS = any> extends ComponentLifecycle<P, S, SS> {
// static whyDidYouRender?: WhyDidYouRender.WhyDidYouRenderComponentMember;
// }
*/
}