Travis
Dec 08 2021 at 15:03 GMT
In my Relay app, I am specifying the environment prop to RelayEnvironmentProvider like this:
const environment = new Environment(config)
<RelayEnvironmentProvider environment={environment}>However, I get the following error about the type of the environment prop:
Property 'getLogger' is missing in type 'RelayModernEnvironment' but required in type 'Environment'.ts(2741)
RelayStoreTypes.d.ts(464, 5): 'getLogger' is declared here.
RelayEnvironmentProvider.d.ts(6, 5): The expected type comes from property 'environment' which is declared here on type 'IntrinsicAttributes & Props'What is causing this type error and how can I fix it?
john
Dec 08 2021 at 15:35 GMT
This is likely happening because @types/react-relay is using a different version of @types/relay-runtime than you are.
You can make @types/react-relay use the same version as you are by specifying a resolution in your package.json. So, if you're using @types/relay-runtime with version 12.0.0, you would add the following:
"resolutions": {
"@types/relay-runtime": "12.0.0"
}Credit for this solution goes to this GitHub comment.