supasate / connected-react-router

A Redux binding for React Router v4
MIT License
4.73k stars 592 forks source link

Missing typing for the default component property `children` for react@17 #570

Open ghost opened 2 years ago

ghost commented 2 years ago

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch connected-react-router@6.9.2 for the project I'm working on.

Here is the diff that solved my problem:

diff --git a/node_modules/connected-react-router/index.d.ts b/node_modules/connected-react-router/index.d.ts
index f2e7bcc..2786540 100644
--- a/node_modules/connected-react-router/index.d.ts
+++ b/node_modules/connected-react-router/index.d.ts
@@ -22,6 +22,7 @@ declare module 'connected-react-router' {
     noInitialPop?: boolean;
     noTimeTravelDebugging?: boolean;
     omitRouter?: boolean;
+    children?: JSX.Element;
   }

   export type RouterActionType = Action;

This issue body was partially generated by patch-package.

wshamim commented 2 years ago

Yeah React is complaining about missing children prop after upgrading to >=17.

TS2769: No overload matches this call.   Overload 1 of 2, '(props: ConnectedRouterProps<PoorMansUnknown> | Readonly<ConnectedRouterProps<PoorMansUnknown>>): ConnectedRouter<...>', gave the following error.     Type '{ children: Element; history: History<PoorMansUnknown>; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<ConnectedRouter<PoorMansUnknown>> & Readonly<...>'.       Property 'children' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<ConnectedRouter<PoorMansUnknown>> & Readonly<...>'.   Overload 2 of 2, '(props: ConnectedRouterProps<PoorMansUnknown>, context: any): ConnectedRouter<PoorMansUnknown>', gave the following error.     Type '{ children: Element; history: History<PoorMansUnknown>; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<ConnectedRouter<PoorMansUnknown>> & Readonly<...>'.       Property 'children' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<ConnectedRouter<PoorMansUnknown>> & Readonly<...>'..

@kpavlov7 thanks for the idea to fix it temporarily with patch-package