facebook / relay

Relay is a JavaScript framework for building data-driven React applications.
https://relay.dev
MIT License
18.38k stars 1.82k forks source link

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

Open jmancherje opened 6 months ago

jmancherje commented 6 months ago

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 commented 6 months ago

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 commented 6 months ago

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)?

kejistan commented 5 months ago

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

kawazoe commented 3 months ago

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

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