Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide an update to work with @types/react@18 #565

Closed
txemaleon opened this issue Apr 12, 2022 · 5 comments
Closed

Provide an update to work with @types/react@18 #565

txemaleon opened this issue Apr 12, 2022 · 5 comments

Comments

@txemaleon
Copy link

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch [email protected] for the project I'm working on.

In the company I'm working on recently updated to react 18 which no longer includes the children property for react components.

This causes our CI Pipeline to blow up when checking types and makes our developer experience worse.

We had to update most of our type packages and some other packages with types included, but we were unable to update connected-react-router since it's already in the last version.

We used patch-package to fix the problem really easily and we wanted to share the solution so you can apply the fix easily (or anyone who runs into this problem).

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..79ed1ff 100644
--- a/node_modules/connected-react-router/index.d.ts
+++ b/node_modules/connected-react-router/index.d.ts
@@ -17,6 +17,7 @@ declare module 'connected-react-router' {
   type PathParam = Parameters<typeof matchPath>[1];
 
   interface ConnectedRouterProps<S = LocationState> {
+    children: React.ReactNode;
     history: History<S>;
     context?: React.Context<ReactReduxContextValue>;
     noInitialPop?: boolean;

This issue body was partially generated by patch-package.

Cheers.

@laurentksh
Copy link

@supasate hey, would be nice to have an official fix for this issue (I can create a PR for it if you want)

@devon-whil
Copy link

See the following comment which has some helpful links:
facebook/react#24304 (comment)

You could argue that the problem is with every package that specifies version * as a dependency.

The longer-term solution to this is being discussed in microsoft/DefinitelyTyped-tools#433.

The short-term workarounds are described in facebook/react#24304 (comment).

@txemaleon
Copy link
Author

We took the fast route and added a @ts-ignore where we use this component and continued to work.

At some point we'll get rid of this package since it isn't maintained anymore.

@antonpegov
Copy link

antonpegov commented May 25, 2022

@txemaleon do you mean connected-react-router isn't maintained anymore?

@txemaleon
Copy link
Author

I'd say so based on the issues list and the lack of responses.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants