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

v16 RelayFieldLogger not available in @types/relay-runtime #4666

Open danielob opened 5 months ago

danielob commented 5 months ago

In version 16, requiredFieldLogger was renamed to relayFieldLogger. (Commit link)

We are utilizing the latest versions of all relevant packages (react-relay, relay-runtime, @types/relay-runtime):

yarn list v1.22.19
warning Filtering by arguments is deprecated. Please use the pattern option instead.
├─ @types/react-relay@16.0.6
├─ @types/relay-runtime@14.1.23
├─ react-relay@16.2.0
├─ relay-compiler@16.2.0
└─ relay-runtime@16.2.0

However, upon inspecting the type definitions in @types/relay-runtime, it appears that the naming has not been updated, causing issues when passing the logger into the relay environment. To address this, we've implemented a workaround as follows:

import { requiredFieldLogger } from 'path/to/our/logger';

const environment = new Environment({
    network,
    store,
    requiredFieldLogger, // required by the definition of EnvironmentConfig in @types/relay-runtime
    // @ts-ignore
    relayFieldLogger: requiredFieldLogger, // without this, we encounter a runtime error 
});

While some discussions mention similar issues with outdated type definitions (link), they do not directly impact us.

Is there any plan to update the type definitions for version 16? If not, what would be the recommended path for contributing changes to the DefinitelyTyped repository?

gajus commented 1 month ago

If anyone needs a quick fix, just add "@types/relay-runtime": "17.0.4", to your pnpm#overrides.