import * as React from "react"; /** * @template T Object * @template K Union of T keys */ export type Omit = Pick>; /** * @template T Object * @template K Union of keys (not necessarily present in T) */ export type Without = Pick>; /** * Transform `"a" | "b"` into `"a" & "b"` * @template U Union */ export type UnionToIntersection = (U extends any ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never; /** * Get component props * @template T Component type */ export type ComponentToProps = T extends | React.ComponentType | React.Component | React.ExoticComponent ? P : never; /** * Use prop * @template P Props type */ export type UseProp

= | keyof JSX.IntrinsicElements | React.ComponentType

; /** * Remove use props from object `T` if they're present * @template T Object */ export type WithoutUseProps = Without; /** * Remove ref prop from object `T` if it's present * @template T Object */ export type WithoutRef = Without; /** * Grab components passed to the `use` prop and return their props * @template T Component type */ export type InheritedProps = WithoutUseProps< UnionToIntersection> >; /** * Props of a component created with `use()` * @template T The type of the `use` prop */ export type UseProps = React.ClassAttributes & InheritedProps & { readonly use?: T | T[]; readonly useNext?: T | T[]; }; /** * Component created with `use()` * @template T Component type passed to `use(...components)` */ export type UseComponent = { (props: WithoutRef> & UseProps): React.ReactElement< any > | null; uses: T[]; propTypes?: any; defaultProps?: any; displayName?: string; };