Export PreloadableConcreteRequest from relay-runtime's Flow types - #5384
Open
GregoryCollett wants to merge 1 commit into
Open
Export PreloadableConcreteRequest from relay-runtime's Flow types#5384GregoryCollett wants to merge 1 commit into
GregoryCollett wants to merge 1 commit into
Conversation
relay-runtime's TypeScript declarations already define
`PreloadableConcreteRequest` in `util/RelayConcreteNode.d.ts` and
re-export it from `index.d.ts`, but the Flow types did not expose it:
the Flow definition only lived in react-relay
(`EntryPointTypes.flow.js`). As a result a Flow consumer could not
`import type {PreloadableConcreteRequest} from 'relay-runtime'`, even
though the equivalent TypeScript import works.
Move the canonical Flow definition down into
`relay-runtime/util/RelayConcreteNode.js` (mirroring the `.d.ts`
layout) and export it from `relay-runtime`'s `index.js`. react-relay's
`EntryPointTypes.flow.js` now imports and re-exports it from
relay-runtime instead of defining its own identical copy, so the type
has a single source of truth. Types-only; no runtime change.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
relay-runtime's TypeScript declarations exposePreloadableConcreteRequest— it is defined inutil/RelayConcreteNode.d.tsand re-exported fromindex.d.ts. The Flow types do not: the Flow definition only lives inreact-relay(relay-hooks/EntryPointTypes.flow.js).So this works for a TypeScript consumer but not the Flow equivalent:
The compiler emits
@preloadable$Parameters.jsartifacts whose type isPreloadableConcreteRequest, so it's natural for eager query-loader code to want the type fromrelay-runtimealongsideRequestParameters,ConcreteRequest, etc.What this does (types-only)
PreloadableConcreteRequestdown intorelay-runtime/util/RelayConcreteNode.js— the same file/location the.d.tsuses — and exports it fromrelay-runtime'sindex.js, matchingindex.d.ts.react-relay'sEntryPointTypes.flow.jsnow imports and re-exports it fromrelay-runtimeinstead of defining an identical local copy, so there's a single source of truth. Every existingimport ... from 'EntryPointTypes'keeps working via the re-export.The Flow definition is unchanged — it's relay's own existing one (
out TQuery extends OperationType, phantom__phantom__?: ?TQuery). No runtime code changes.Notes
OperationTypeis imported intoRelayConcreteNode.jsfrom the sibling./RelayRuntimeTypes(same import the.d.tsalready uses);RelayRuntimeTypesdoes not importRelayConcreteNode, so no cycle is introduced.