Skip to content

Commit

Permalink
Use conditional type to power EntryPointElementConfig
Browse files Browse the repository at this point in the history
Reviewed By: panagosg7

Differential Revision: D51694032

fbshipit-source-id: 928c7489736b2308288dff6e7ae88c060386716e
  • Loading branch information
SamChou19815 authored and facebook-github-bot committed Dec 3, 2023
1 parent 1b65edd commit e694ba8
Showing 1 changed file with 16 additions and 18 deletions.
34 changes: 16 additions & 18 deletions packages/react-relay/relay-hooks/EntryPointTypes.flow.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,24 +214,22 @@ export type PreloadedEntryPoint<TEntryPointComponent> = $ReadOnly<{
rootModuleID: string,
}>;

type _ComponentFromEntryPoint = <
TPreloadParams,
// $FlowFixMe[unsupported-variance-annotation]
+TComponent,
// $FlowFixMe[unsupported-variance-annotation]
+TEntryPoint: EntryPoint<TPreloadParams, TComponent>,
>(
TEntryPoint,
) => TComponent;

type ComponentFromEntryPoint<+TEntryPoint> = $Call<
_ComponentFromEntryPoint,
TEntryPoint,
>;

export type EntryPointElementConfig<+TEntryPoint> = ElementConfig<
ComponentFromEntryPoint<TEntryPoint>,
>['props'];
export type EntryPointElementConfig<
// $FlowExpectedError[unclear-type] Need any to make it supertype of all InternalEntryPointRepresentation
+TEntryPoint: InternalEntryPointRepresentation<any, any, any, any, any>,
> = TEntryPoint extends InternalEntryPointRepresentation<
// $FlowExpectedError[unclear-type] Need any to make it supertype of all InternalEntryPointRepresentation
any,
// $FlowExpectedError[unclear-type] Need any to make it supertype of all InternalEntryPointRepresentation
any,
// $FlowExpectedError[unclear-type] Need any to make it supertype of all InternalEntryPointRepresentation
any,
infer Props,
// $FlowExpectedError[unclear-type] Need any to make it supertype of all InternalEntryPointRepresentation
any,
>
? Props
: empty;

export type ThinQueryParams<
TQuery: OperationType,
Expand Down

0 comments on commit e694ba8

Please sign in to comment.