import * as React from 'react'; /** * React.Ref uses the readonly type `React.RefObject` instead of * `React.MutableRefObject`, We pretty much always assume ref objects are * mutable (at least when we create them), so this type is a workaround so some * of the weird mechanics of using refs with TS. */ export declare type AssignableRef = { bivarianceHack(instance: ValueType | null): void; }['bivarianceHack'] | React.MutableRefObject; /** * Type can be either a single `ValueType` or an array of `ValueType` */ export declare type SingleOrArray = ValueType[] | ValueType; /** * The built-in utility type `Omit` does not distribute over unions. So if you * have: * * type A = { a: 'whatever' } * * and you want to do a union with: * * type B = A & { b: number } | { b: string; c: number } * * you might expect `Omit` to give you: * * type B = * | Omit<{ a: "whatever"; b: number }, "a"> | Omit<{ a: "whatever"; b: string; c: number }, "a">; * * This is not the case, unfortunately, so we need to create our own version of * `Omit` that distributes over unions with a distributive conditional type. If * you have a generic type parameter `T`, then the construct * `T extends any ? F : never` will end up distributing the `F<>` operation * over `T` when `T` is a union type. * * @link https://stackoverflow.com/a/59796484/1792019 * @link http://www.typescriptlang.org/docs/handbook/advanced-types.html#distributive-conditional-types */ export declare type DistributiveOmit = BaseType extends any ? Omit : never; /** * Returns the type inferred by a promise's return value. * * @example * async function getThing() { * // return type is a number * let result: number = await fetchValueSomewhere(); * return result; * } * * type Thing = ThenArg>; * // number */ export declare type ThenArg = T extends PromiseLike ? U : T; export declare type As = React.ElementType; export declare type PropsWithAs = ComponentProps & Omit, 'as' | keyof ComponentProps> & { as?: ComponentType; }; export declare type PropsFromAs = (PropsWithAs & { as: ComponentType; }) & PropsWithAs; export declare type ComponentWithForwardedRef = React.ForwardRefExoticComponent> & React.ComponentPropsWithRef>; export interface FunctionComponentWithAs { /** * Inherited from React.FunctionComponent with modifications to support `as` */ (props: PropsWithAs, context?: any): React.ReactElement | null; (props: PropsWithAs, context?: any): React.ReactElement | null; /** * Inherited from React.FunctionComponent */ displayName?: string; propTypes?: React.WeakValidationMap>; contextTypes?: React.ValidationMap; defaultProps?: Partial>; } export interface ComponentWithAs extends FunctionComponentWithAs { } interface ExoticComponentWithAs { /** * **NOTE**: Exotic components are not callable. * Inherited from React.ExoticComponent with modifications to support `as` */ (props: PropsWithAs): React.ReactElement | null; (props: PropsWithAs & { as: ComponentType; }): React.ReactElement | null; /** * Inherited from React.ExoticComponent */ readonly $$typeof: symbol; } interface NamedExoticComponentWithAs extends ExoticComponentWithAs { /** * Inherited from React.NamedExoticComponent */ displayName?: string; } export interface ForwardRefExoticComponentWithAs extends NamedExoticComponentWithAs { /** * Inherited from React.ForwardRefExoticComponent * Will show `ForwardRef(${Component.displayName || Component.name})` in devtools by default, * but can be given its own specific name */ defaultProps?: Partial>; propTypes?: React.WeakValidationMap>; } export interface MemoExoticComponentWithAs extends NamedExoticComponentWithAs { readonly type: DefaultComponentType extends React.ComponentType ? DefaultComponentType : FunctionComponentWithAs; } export interface ForwardRefWithAsRenderFunction { (props: React.PropsWithChildren>, ref: ((instance: (DefaultComponentType extends keyof ElementTagNameMap ? ElementTagNameMap[DefaultComponentType] : any) | null) => void) | React.MutableRefObject<(DefaultComponentType extends keyof ElementTagNameMap ? ElementTagNameMap[DefaultComponentType] : any) | null> | null): React.ReactElement | null; displayName?: string; /** * defaultProps are not supported on render functions */ defaultProps?: never; /** * propTypes are not supported on render functions */ propTypes?: never; } export declare type ElementTagNameMap = HTMLElementTagNameMap & Pick>; export {};