relay icon indicating copy to clipboard operation
relay copied to clipboard

Relay Environment type issues when upgrading to react-relay 16.x

Open jmancherje opened this issue 11 months ago • 4 comments

tl;dr we are seeing Type 'RelayModernEnvironment' is not assignable to type 'Environment'. after upgrading even with code right from docs.

We are attempting to upgrade from react-relay 14.x to 16.0.0. Our dependencies are now: react-relay 16.0.0, relay-runtime 16.0.0, @types/react-relay 16.0.0, @types/relay-runtime 14.1.15, babel-plugin-relay 16.0.0, relay-compiler 16.0.0.

We are seeing Type 'RelayModernEnvironment' is not assignable to type 'Environment'. with all our uses of environment.

I simplified the case by copying this set up right from the docs for RelayEnvironmentProvider here:

image image

Because this is just passing in the environment directly from new Environment(..) as the docs show I'm not sure what the issue is with the RelayModernEnvironment vs Environment

jmancherje avatar Mar 22 '24 22:03 jmancherje

I didn't notice this before but I see this same issue came up in 2021 for different versions of relay and relay-types https://github.com/facebook/relay/issues/3697

jmancherje avatar Mar 22 '24 22:03 jmancherje

If this is the same problem, and DefinitelyTyped hasn't been updated to support the latest relay types, does this mean people with TypeScript and relay 15/16 are not using DefinitelyTyped (or that not many people are using TS on the latest version)?

jmancherje avatar Mar 25 '24 21:03 jmancherje

It looks like you probably have two different versions of @types/relay-runtime in your node_modules.

kejistan avatar Apr 03 '24 00:04 kejistan

Similar issue here since January: https://github.com/facebook/relay/issues/4598

Everything works fine with previous versions of @types/react.

kawazoe avatar Jun 17 '24 21:06 kawazoe