@donverduyn/react-runtime
Version:
effect-ts react integration
19 lines (18 loc) • 1.14 kB
TypeScript
import * as React from 'react';
import type { Simplify, Merge, IsUnknown, IsNever } from 'type-fest';
import { type PROPS_PROP, type ExtractStaticProps, type IdProp, type ERROR_PROP } from '@/types';
import { type ExtractMeta } from '@/utils/react';
type PropsOrEmpty<P> = keyof P extends never ? Record<never, never> : P;
export declare function WithProviderScope<C1 extends React.FC<any>, CProps, PProps, PErrors>(RootComponent: C1, rootProps?: PropsOrEmpty<React.ComponentProps<C1>>): (Component: ({
[PROPS_PROP]: PProps;
} & React.FC<CProps>) | ({
[ERROR_PROP]: PErrors;
} & React.FC<CProps>) | React.FC<CProps>) => IsUnknown<PErrors> extends true ? React.FC<Simplify<Partial<IdProp> & CProps>> & StaticProperties<React.FC<Simplify<CProps>>, PProps, PErrors> : React.FC<Simplify<CProps>> & {
_error: ['Type mismatch on provided props'];
};
type StaticProperties<C, TProps, TErrors = unknown> = TErrors extends [string] ? Merge<ExtractMeta<C>, {
[ERROR_PROP]: TErrors;
}> : Merge<ExtractMeta<C>, {
[PROPS_PROP]: IsNever<TProps> extends false ? Merge<ExtractStaticProps<C>, TProps> : ExtractStaticProps<C>;
}>;
export {};