import React from 'react'; export declare type Omit = Pick>; export declare type Shared = { [P in Extract]?: A[P] extends B[P] ? B[P] : never; } & { [P in Extract]?: B[P] extends A[P] ? A[P] : never; }; /** * Extract the type of "P" for a given React component */ export declare type PropsOf = C extends new (props: infer P) => React.Component ? P : C extends (props: infer P) => React.ReactElement | null ? P : C extends React.Component ? P : never; export declare const withDefaultProps: >(defaultProps: DP, Component: React.ComponentType

) => React.ComponentType | Extract>>>> & Pick | Extract>>>; export declare type ResultantProps = Omit; /** * This type is used for HOC's that do not inject any props rather just render * the component in a special way. The resultant component can take in additional * props. * * Example usage: * * const withDeprecationWarnings: PropsPasser = ( * Component, * ) => { * return class WithDeprecationWarnings extends React.Component & AppearanceProps> { * static displayName = `WithDeprecationWarnings(${getComponentName( * Component, * )})`; * * UNSAFE_componentWillMount() { * warnIfDeprecatedAppearance(this.props.appearance); * } * * UNSAFE_componentWillReceiveProps(newProps: AppearanceProps) { * if (newProps.appearance !== this.props.appearance) { * warnIfDeprecatedAppearance(newProps.appearance); * } * } * * render() { * return React.createElement(Component, this.props as any); * } * }; * }; */ export declare type PropsPasser = (Component: C) => React.ComponentClass & Extra>; /** * Sometimes we want to utilse the power of Algebraic Data Types. * Meaning, ADTs behave similarly to algebra: * - (a + b) * c === a * c + b * c * - (A | B) & T === (A & T) | (B & T). * * As such, if I have props for my component as a * Sum type (also called variants), like this: * * type Props = {a: number} | {b: string} * * and I want to build up NewProps by mixing-in: * * type NewProps * = Props & { data: bool } * === ({a: number} & { data: bool } ) | ( {b: string} & { data: bool } ) */ export declare type SumPropsInjector = >(Component: C) => React.ComponentClass & InjectedProps>; /** * Returns a type with keys that are not in T and U set to never. * For example: * ``` * interface T { * foo: string; * } * interface U { * foo: string; * bar: string; * } * type Result = Without; * // Result === { bar?: never }; * ``` */ export declare type Without = { [P in Exclude]?: never; }; /** * Returns type that accepts either one of two provided types. * For example: * ``` * interface T{ * foo: string; * } * interface U{ * bar: string; * } * type OneOfTwo = XOR * * const one: OneOfTwo = {foo: "hello"}; * const two: OneOfTwo = {bar: "hello"}; * * const error: OneOfTwo = {foo: "hello", bar: "hello"}; // Throws an error * * console.log(one.foo); // OK * console.log(one.bar); // ERROR * console.log(two.bar); // OK * console.log(two.foo); // ERROR * ``` * * But! There is a catch. * ``` * function(oneOrTwo: OneOrTwo) { * console.log(oneOrTwo.foo); // OK * console.log(oneOrTwo.bar); // OK * } * ``` * This is somewhat buggy in that context, so you should be careful reading values checking them * manually first. * */ export declare type XOR = T | U extends object ? (Without & U) | (Without & T) : T | U;