question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

@types/react 18.0.0 not compatible with Easy Peasy

See original GitHub issue

I am getting a Typescript error if I upgrade @types/react to version 18.0.0 and use Easy Peasy:

Type error: No overload matches this call.

Overload 1 of 2, '(props: { store: Store<StoreModel, EasyPeasyConfig<undefined, {}>>; } | Readonly<{ store: Store<StoreModel, EasyPeasyConfig<undefined, {}>>; }>): StoreProvider<...>', gave the following error.

Overload 2 of 2, '(props: { store: Store<StoreModel, EasyPeasyConfig<undefined, {}>>; }, context: any): StoreProvider<StoreModel>', gave the following error.

     <StoreProvider store={store}>
     <Component {...pageProps} />
      </StoreProvider>

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:14
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

17reactions
asirakycommented, May 25, 2022

I believe the more correct way to augment the type is to do the following:

type Props = StoreProvider["props"] & { children: React.ReactNode }

const StoreProviderCasted = StoreProvider as unknown as React.ComponentType<Props>

function WebAppContainer() {
    return (
        <StoreProviderCasted store={webAppStore}>
            ...
        </StoreProviderCasted>
    )
}

This will keep all the strong typing and add the children prop back to the type.

4reactions
wclearcommented, Apr 27, 2022

Here is an example of how to temporarily workaround this issue until the fix is published:

...
import { StoreProvider } from 'easy-peasy';

const StoreProviderOverride = StoreProvider as any;

function WebAppContainer() {
	return (
		<StoreProviderOverride store={webAppStore}>
			...
		</StoreProviderOverride>
	)
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

@types/react - npm
Start using @types/react in your project by running `npm i ... TypeScript icon, indicating that this package has built-in type declarations.
Read more >
Upgrading @types/react to 18.0.0 gives no overload matches ...
In my code I just want to use a generic type MyProps and my function accepts a parameter of ComponentClass. This started throwing...
Read more >
React 18 is not compatible with Fluent UI and how to work ...
The reason in both cases for the error is that once React 18 is installed, Fluent UI will not install since it requires...
Read more >
npm eresolve could not resolve - You.com | The AI Search ...
The error is telling you that react-scripts@4.0.0 supports typescript@^3.2.1 (i.e. TypeScript >=3.2.1, <4) as a peer dependency. Your dev dependencies have ...
Read more >
Upgrading to new versions - React Native
I want to upgrade with React Native CLI but I don't use Git​. While your project does not have to be handled by...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found