@saneksa/react-context-composer
Version:
[](https://npmjs.com/package/@saneksa/react-context-composer/) [](http
11 lines (8 loc) • 525 B
TypeScript
import * as react_jsx_runtime from 'react/jsx-runtime';
import { ReactNode, Context } from 'react';
type ContextTuple<C, V = C> = readonly [Context<C>, V];
type ContextValues<T> = {
[K in keyof T]: T[K] extends ContextTuple<infer C, infer V> ? V extends C ? ContextTuple<C, V> : ContextTuple<C> : ContextTuple<any>;
} & ReadonlyArray<ContextTuple<any>>;
declare function composeContexts<const T extends ContextValues<T>>(wrappers: T): (children: ReactNode) => react_jsx_runtime.JSX.Element;
export { composeContexts };