Skip to content

Commit 91f21b2

Browse files
authored
Fix compatibility of createDevTools with React 19 types (#1837)
* Fix compatibility of createDevTools with React 19 types * Create fluffy-keys-doubt.md
1 parent ff60266 commit 91f21b2

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

.changeset/fluffy-keys-doubt.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@redux-devtools/core': patch
3+
---
4+
5+
Fix compatibility of createDevTools with React 19 types

packages/redux-devtools/src/createDevTools.tsx

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ import {
66
LiftedState,
77
LiftedStore,
88
Options,
9+
InstrumentExt,
910
} from '@redux-devtools/instrument';
10-
import { Action } from 'redux';
11+
import { Action, StoreEnhancer } from 'redux';
1112

1213
function logError(type: string) {
1314
if (type === 'NoStore') {
@@ -46,13 +47,32 @@ export type Monitor<
4647
}
4748
>;
4849

50+
export interface DevToolsInstance<S, A extends Action<string>, MonitorState>
51+
extends Component<Props<S, A, MonitorState>> {
52+
liftedStore?: LiftedStore<S, A, MonitorState>;
53+
}
54+
55+
export interface DevToolsClass<
56+
S,
57+
A extends Action<string>,
58+
MonitorState,
59+
MonitorAction extends Action<string>,
60+
> {
61+
new (props: Props<S, A, MonitorState>): DevToolsInstance<S, A, MonitorState>;
62+
instrument: (
63+
options?: Options<S, A, MonitorState, MonitorAction>,
64+
) => StoreEnhancer<InstrumentExt<any, any, MonitorState>>;
65+
}
66+
4967
export default function createDevTools<
5068
S,
5169
A extends Action<string>,
5270
MonitorProps extends LiftedState<S, A, MonitorState>,
5371
MonitorState,
5472
MonitorAction extends Action<string>,
55-
>(children: Monitor<S, A, MonitorProps, MonitorState, MonitorAction>) {
73+
>(
74+
children: Monitor<S, A, MonitorProps, MonitorState, MonitorAction>,
75+
): DevToolsClass<S, A, MonitorState, MonitorAction> {
5676
const monitorElement = Children.only(children);
5777
const monitorProps = monitorElement.props;
5878
const Monitor = monitorElement.type;

0 commit comments

Comments
 (0)