Skip to content

Latest commit

 

History

History
626 lines (574 loc) · 18.1 KB

File metadata and controls

626 lines (574 loc) · 18.1 KB

API Report File for "react-redux"

Do not edit this file. It is a report generated by API Extractor.

/// <reference types="react" />

import { Action } from 'redux'
import { AnyAction } from 'redux'
import { unstable_batchedUpdates as batch } from 'react-dom'
import { ClassAttributes } from 'react'
import { ComponentClass } from 'react'
import { ComponentType } from 'react'
import { Context } from 'react'
import { Dispatch } from 'redux'
import type { NonReactStatics } from 'hoist-non-react-statics'
import { default as React_2 } from 'react'
import { ReactNode } from 'react'
import { Store } from 'redux'

// @public (undocumented)
export type AdvancedComponentDecorator<TProps, TOwnProps> = (
  component: ComponentType<TProps>,
) => ComponentType<TOwnProps>

// @public (undocumented)
export type AnyIfEmpty<T extends object> = keyof T extends never ? any : T

export { batch }

// @public (undocumented)
export const connect: {
  (): InferableComponentEnhancer<DispatchProp>
  <
    TStateProps = {},
    no_dispatch = {},
    TOwnProps = {},
    State = DefaultRootState,
  >(
    mapStateToProps: MapStateToPropsParam<TStateProps, TOwnProps, State>,
  ): InferableComponentEnhancerWithProps<
    TStateProps & DispatchProp<AnyAction>,
    TOwnProps
  >
  <no_state = {}, TDispatchProps = {}, TOwnProps_1 = {}>(
    mapStateToProps: null | undefined,
    mapDispatchToProps: MapDispatchToPropsNonObject<
      TDispatchProps,
      TOwnProps_1
    >,
  ): InferableComponentEnhancerWithProps<TDispatchProps, TOwnProps_1>
  <no_state_1 = {}, TDispatchProps_1 = {}, TOwnProps_2 = {}>(
    mapStateToProps: null | undefined,
    mapDispatchToProps: MapDispatchToPropsParam<TDispatchProps_1, TOwnProps_2>,
  ): InferableComponentEnhancerWithProps<
    ResolveThunks<TDispatchProps_1>,
    TOwnProps_2
  >
  <
    TStateProps_1 = {},
    TDispatchProps_2 = {},
    TOwnProps_3 = {},
    State_1 = DefaultRootState,
  >(
    mapStateToProps: MapStateToPropsParam<TStateProps_1, TOwnProps_3, State_1>,
    mapDispatchToProps: MapDispatchToPropsNonObject<
      TDispatchProps_2,
      TOwnProps_3
    >,
  ): InferableComponentEnhancerWithProps<
    TStateProps_1 & TDispatchProps_2,
    TOwnProps_3
  >
  <
    TStateProps_2 = {},
    TDispatchProps_3 = {},
    TOwnProps_4 = {},
    State_2 = DefaultRootState,
  >(
    mapStateToProps: MapStateToPropsParam<TStateProps_2, TOwnProps_4, State_2>,
    mapDispatchToProps: MapDispatchToPropsParam<TDispatchProps_3, TOwnProps_4>,
  ): InferableComponentEnhancerWithProps<
    TStateProps_2 & ResolveThunks<TDispatchProps_3>,
    TOwnProps_4
  >
  <no_state_2 = {}, no_dispatch_1 = {}, TOwnProps_5 = {}, TMergedProps = {}>(
    mapStateToProps: null | undefined,
    mapDispatchToProps: null | undefined,
    mergeProps: MergeProps<undefined, undefined, TOwnProps_5, TMergedProps>,
  ): InferableComponentEnhancerWithProps<TMergedProps, TOwnProps_5>
  <
    TStateProps_3 = {},
    no_dispatch_2 = {},
    TOwnProps_6 = {},
    TMergedProps_1 = {},
    State_3 = DefaultRootState,
  >(
    mapStateToProps: MapStateToPropsParam<TStateProps_3, TOwnProps_6, State_3>,
    mapDispatchToProps: null | undefined,
    mergeProps: MergeProps<
      TStateProps_3,
      undefined,
      TOwnProps_6,
      TMergedProps_1
    >,
  ): InferableComponentEnhancerWithProps<TMergedProps_1, TOwnProps_6>
  <
    no_state_3 = {},
    TDispatchProps_4 = {},
    TOwnProps_7 = {},
    TMergedProps_2 = {},
  >(
    mapStateToProps: null | undefined,
    mapDispatchToProps: MapDispatchToPropsParam<TDispatchProps_4, TOwnProps_7>,
    mergeProps: MergeProps<
      undefined,
      TDispatchProps_4,
      TOwnProps_7,
      TMergedProps_2
    >,
  ): InferableComponentEnhancerWithProps<TMergedProps_2, TOwnProps_7>
  <
    TStateProps_4 = {},
    no_dispatch_3 = {},
    TOwnProps_8 = {},
    State_4 = DefaultRootState,
  >(
    mapStateToProps: MapStateToPropsParam<TStateProps_4, TOwnProps_8, State_4>,
    mapDispatchToProps: null | undefined,
    mergeProps: null | undefined,
    options: ConnectOptions<State_4, TStateProps_4, TOwnProps_8, {}>,
  ): InferableComponentEnhancerWithProps<
    DispatchProp<AnyAction> & TStateProps_4,
    TOwnProps_8
  >
  <TStateProps_5 = {}, TDispatchProps_5 = {}, TOwnProps_9 = {}>(
    mapStateToProps: null | undefined,
    mapDispatchToProps: MapDispatchToPropsNonObject<
      TDispatchProps_5,
      TOwnProps_9
    >,
    mergeProps: null | undefined,
    options: ConnectOptions<{}, TStateProps_5, TOwnProps_9, {}>,
  ): InferableComponentEnhancerWithProps<TDispatchProps_5, TOwnProps_9>
  <TStateProps_6 = {}, TDispatchProps_6 = {}, TOwnProps_10 = {}>(
    mapStateToProps: null | undefined,
    mapDispatchToProps: MapDispatchToPropsParam<TDispatchProps_6, TOwnProps_10>,
    mergeProps: null | undefined,
    options: ConnectOptions<{}, TStateProps_6, TOwnProps_10, {}>,
  ): InferableComponentEnhancerWithProps<
    ResolveThunks<TDispatchProps_6>,
    TOwnProps_10
  >
  <
    TStateProps_7 = {},
    TDispatchProps_7 = {},
    TOwnProps_11 = {},
    State_5 = DefaultRootState,
  >(
    mapStateToProps: MapStateToPropsParam<TStateProps_7, TOwnProps_11, State_5>,
    mapDispatchToProps: MapDispatchToPropsNonObject<
      TDispatchProps_7,
      TOwnProps_11
    >,
    mergeProps: null | undefined,
    options: ConnectOptions<State_5, TStateProps_7, TOwnProps_11, {}>,
  ): InferableComponentEnhancerWithProps<
    TStateProps_7 & TDispatchProps_7,
    TOwnProps_11
  >
  <
    TStateProps_8 = {},
    TDispatchProps_8 = {},
    TOwnProps_12 = {},
    State_6 = DefaultRootState,
  >(
    mapStateToProps: MapStateToPropsParam<TStateProps_8, TOwnProps_12, State_6>,
    mapDispatchToProps: MapDispatchToPropsParam<TDispatchProps_8, TOwnProps_12>,
    mergeProps: null | undefined,
    options: ConnectOptions<State_6, TStateProps_8, TOwnProps_12, {}>,
  ): InferableComponentEnhancerWithProps<
    TStateProps_8 & ResolveThunks<TDispatchProps_8>,
    TOwnProps_12
  >
  <
    TStateProps_9 = {},
    TDispatchProps_9 = {},
    TOwnProps_13 = {},
    TMergedProps_3 = {},
    State_7 = DefaultRootState,
  >(
    mapStateToProps: MapStateToPropsParam<TStateProps_9, TOwnProps_13, State_7>,
    mapDispatchToProps: MapDispatchToPropsParam<TDispatchProps_9, TOwnProps_13>,
    mergeProps: MergeProps<
      TStateProps_9,
      TDispatchProps_9,
      TOwnProps_13,
      TMergedProps_3
    >,
    options?:
      | ConnectOptions<State_7, TStateProps_9, TOwnProps_13, TMergedProps_3>
      | undefined,
  ): InferableComponentEnhancerWithProps<TMergedProps_3, TOwnProps_13>
}

// @public (undocumented)
export function connectAdvanced<S, TProps, TOwnProps, TFactoryOptions = {}>(
  selectorFactory: SelectorFactory<S, TProps, unknown, unknown>,
  {
    getDisplayName,
    methodName,
    shouldHandleStateChanges,
    forwardRef,
    context,
    ...connectOptions
  }?: ConnectAdvancedOptions & Partial<TFactoryOptions>,
): AdvancedComponentDecorator<TProps, TOwnProps & ConnectProps>

// @public (undocumented)
export interface ConnectAdvancedOptions {
  // (undocumented)
  context?: typeof ReactReduxContext
  // (undocumented)
  forwardRef?: boolean
  // (undocumented)
  getDisplayName?: (name: string) => string
  // (undocumented)
  methodName?: string
  // (undocumented)
  pure?: boolean
  // (undocumented)
  shouldHandleStateChanges?: boolean
}

// @public (undocumented)
export type ConnectedComponent<
  C extends ComponentType<any>,
  P,
> = ComponentType<P> &
  NonReactStatics<C> & {
    WrappedComponent: C
  }

// @public
export type ConnectedProps<TConnector> =
  TConnector extends InferableComponentEnhancerWithProps<
    infer TInjectedProps,
    any
  >
    ? unknown extends TInjectedProps
      ? TConnector extends InferableComponentEnhancer<infer TInjectedProps>
        ? TInjectedProps
        : never
      : TInjectedProps
    : never

// @public (undocumented)
export interface ConnectProps {
  // (undocumented)
  context?: ReactReduxContextInstance
  // (undocumented)
  reactReduxForwardedRef?: React_2.ForwardedRef<unknown>
  // (undocumented)
  store?: Store
}

// @public
export function createDispatchHook(
  context?: Context<ReactReduxContextValue<any, AnyAction> | null>,
): () => Dispatch<AnyAction>

// @public
export function createSelectorHook(
  context?: Context<ReactReduxContextValue<any, AnyAction> | null>,
): <TState = DefaultRootState, Selected = unknown>(
  selector: (state: TState) => Selected,
  equalityFn?: EqualityFn<Selected>,
) => Selected

// @public
export function createStoreHook(
  context?: Context<ReactReduxContextValue<any, AnyAction> | null>,
): () => Store<any, AnyAction>

// @public
export interface DefaultRootState {}

// @public (undocumented)
export interface DispatchProp<A extends Action = AnyAction> {
  // (undocumented)
  dispatch: Dispatch<A>
}

// @public (undocumented)
export type DistributiveOmit<T, K extends keyof T> = T extends unknown
  ? Omit_2<T, K>
  : never

// @public (undocumented)
export type EqualityFn<T> = (a: T | undefined, b: T | undefined) => boolean

// @public (undocumented)
export type FixTypeLater = any

// @public (undocumented)
export type GetProps<C> =
  C extends ComponentType<infer P>
    ? C extends ComponentClass<P>
      ? ClassAttributes<InstanceType<C>> & P
      : P
    : never

// @public (undocumented)
export type HandleThunkActionCreator<TActionCreator> = TActionCreator extends (
  ...args: any[]
) => any
  ? InferThunkActionCreatorType<TActionCreator>
  : TActionCreator

// @public (undocumented)
export type InferableComponentEnhancer<TInjectedProps> =
  InferableComponentEnhancerWithProps<TInjectedProps, {}>

// @public (undocumented)
export type InferableComponentEnhancerWithProps<TInjectedProps, TNeedsProps> = <
  C extends ComponentType<Matching<TInjectedProps, GetProps<C>>>,
>(
  component: C,
) => ConnectedComponent<
  C,
  DistributiveOmit<GetProps<C>, keyof Shared<TInjectedProps, GetProps<C>>> &
    TNeedsProps
>

// @public (undocumented)
export type InferThunkActionCreatorType<
  TActionCreator extends (...args: any[]) => any,
> = TActionCreator extends (
  ...args: infer TParams
) => (...args: any[]) => infer TReturn
  ? (...args: TParams) => TReturn
  : TActionCreator

// @public (undocumented)
export type MapDispatchToProps<TDispatchProps, TOwnProps> =
  | MapDispatchToPropsFunction<TDispatchProps, TOwnProps>
  | TDispatchProps

// @public (undocumented)
export type MapDispatchToPropsFactory<TDispatchProps, TOwnProps> = (
  dispatch: Dispatch<Action>,
  ownProps: TOwnProps,
) => MapDispatchToPropsFunction<TDispatchProps, TOwnProps>

// @public (undocumented)
export type MapDispatchToPropsFunction<TDispatchProps, TOwnProps> = (
  dispatch: Dispatch<Action>,
  ownProps: TOwnProps,
) => TDispatchProps

// @public (undocumented)
export type MapDispatchToPropsNonObject<TDispatchProps, TOwnProps> =
  | MapDispatchToPropsFactory<TDispatchProps, TOwnProps>
  | MapDispatchToPropsFunction<TDispatchProps, TOwnProps>

// @public (undocumented)
export type MapDispatchToPropsParam<TDispatchProps, TOwnProps> =
  | MapDispatchToPropsFactory<TDispatchProps, TOwnProps>
  | MapDispatchToProps<TDispatchProps, TOwnProps>

// @public (undocumented)
export type MapStateToProps<
  TStateProps,
  TOwnProps,
  State = DefaultRootState,
> = (state: State, ownProps: TOwnProps) => TStateProps

// @public (undocumented)
export type MapStateToPropsFactory<
  TStateProps,
  TOwnProps,
  State = DefaultRootState,
> = (
  initialState: State,
  ownProps: TOwnProps,
) => MapStateToProps<TStateProps, TOwnProps, State>

// @public (undocumented)
export type MapStateToPropsParam<
  TStateProps,
  TOwnProps,
  State = DefaultRootState,
> =
  | MapStateToPropsFactory<TStateProps, TOwnProps, State>
  | MapStateToProps<TStateProps, TOwnProps, State>
  | null
  | undefined

// @public
export type Matching<InjectedProps, DecorationTargetProps> = {
  [P in keyof DecorationTargetProps]: P extends keyof InjectedProps
    ? InjectedProps[P] extends DecorationTargetProps[P]
      ? DecorationTargetProps[P]
      : InjectedProps[P]
    : DecorationTargetProps[P]
}

// @public (undocumented)
export type MergeProps<TStateProps, TDispatchProps, TOwnProps, TMergedProps> = (
  stateProps: TStateProps,
  dispatchProps: TDispatchProps,
  ownProps: TOwnProps,
) => TMergedProps

// @public (undocumented)
type Omit_2<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>
export { Omit_2 as Omit }

// @public (undocumented)
export function Provider({
  store,
  context,
  children,
}: ProviderProps): JSX.Element

// @public (undocumented)
export interface ProviderProps<A extends Action = AnyAction> {
  // (undocumented)
  children: ReactNode
  context?: Context<ReactReduxContextValue>
  store: Store<FixTypeLater, A>
}

// @public (undocumented)
export const ReactReduxContext: React_2.Context<ReactReduxContextValue<
  any,
  AnyAction
> | null>

// @public (undocumented)
export interface ReactReduxContextValue<
  SS = FixTypeLater,
  A extends Action = AnyAction,
> {
  // (undocumented)
  store: Store<SS, A>
  // (undocumented)
  subscription: Subscription
}

// @public (undocumented)
export type ResolveArrayThunks<TDispatchProps extends ReadonlyArray<any>> =
  TDispatchProps extends [
    infer A1,
    infer A2,
    infer A3,
    infer A4,
    infer A5,
    infer A6,
    infer A7,
    infer A8,
    infer A9,
  ]
    ? [
        HandleThunkActionCreator<A1>,
        HandleThunkActionCreator<A2>,
        HandleThunkActionCreator<A3>,
        HandleThunkActionCreator<A4>,
        HandleThunkActionCreator<A5>,
        HandleThunkActionCreator<A6>,
        HandleThunkActionCreator<A7>,
        HandleThunkActionCreator<A8>,
        HandleThunkActionCreator<A9>,
      ]
    : TDispatchProps extends [
          infer A1,
          infer A2,
          infer A3,
          infer A4,
          infer A5,
          infer A6,
          infer A7,
          infer A8,
        ]
      ? [
          HandleThunkActionCreator<A1>,
          HandleThunkActionCreator<A2>,
          HandleThunkActionCreator<A3>,
          HandleThunkActionCreator<A4>,
          HandleThunkActionCreator<A5>,
          HandleThunkActionCreator<A6>,
          HandleThunkActionCreator<A7>,
          HandleThunkActionCreator<A8>,
        ]
      : TDispatchProps extends [
            infer A1,
            infer A2,
            infer A3,
            infer A4,
            infer A5,
            infer A6,
            infer A7,
          ]
        ? [
            HandleThunkActionCreator<A1>,
            HandleThunkActionCreator<A2>,
            HandleThunkActionCreator<A3>,
            HandleThunkActionCreator<A4>,
            HandleThunkActionCreator<A5>,
            HandleThunkActionCreator<A6>,
            HandleThunkActionCreator<A7>,
          ]
        : TDispatchProps extends [
              infer A1,
              infer A2,
              infer A3,
              infer A4,
              infer A5,
              infer A6,
            ]
          ? [
              HandleThunkActionCreator<A1>,
              HandleThunkActionCreator<A2>,
              HandleThunkActionCreator<A3>,
              HandleThunkActionCreator<A4>,
              HandleThunkActionCreator<A5>,
              HandleThunkActionCreator<A6>,
            ]
          : TDispatchProps extends [
                infer A1,
                infer A2,
                infer A3,
                infer A4,
                infer A5,
              ]
            ? [
                HandleThunkActionCreator<A1>,
                HandleThunkActionCreator<A2>,
                HandleThunkActionCreator<A3>,
                HandleThunkActionCreator<A4>,
                HandleThunkActionCreator<A5>,
              ]
            : TDispatchProps extends [infer A1, infer A2, infer A3, infer A4]
              ? [
                  HandleThunkActionCreator<A1>,
                  HandleThunkActionCreator<A2>,
                  HandleThunkActionCreator<A3>,
                  HandleThunkActionCreator<A4>,
                ]
              : TDispatchProps extends [infer A1, infer A2, infer A3]
                ? [
                    HandleThunkActionCreator<A1>,
                    HandleThunkActionCreator<A2>,
                    HandleThunkActionCreator<A3>,
                  ]
                : TDispatchProps extends [infer A1, infer A2]
                  ? [HandleThunkActionCreator<A1>, HandleThunkActionCreator<A2>]
                  : TDispatchProps extends [infer A1]
                    ? [HandleThunkActionCreator<A1>]
                    : TDispatchProps extends Array<infer A>
                      ? Array<HandleThunkActionCreator<A>>
                      : TDispatchProps extends ReadonlyArray<infer A>
                        ? ReadonlyArray<HandleThunkActionCreator<A>>
                        : never

// @public (undocumented)
export type ResolveThunks<TDispatchProps> = TDispatchProps extends {
  [key: string]: any
}
  ? {
      [C in keyof TDispatchProps]: HandleThunkActionCreator<TDispatchProps[C]>
    }
  : TDispatchProps

// @public (undocumented)
export type RootStateOrAny = AnyIfEmpty<DefaultRootState>

// @public (undocumented)
export type Selector<S, TProps, TOwnProps = null> = TOwnProps extends
  | null
  | undefined
  ? (state: S) => TProps
  : (state: S, ownProps: TOwnProps) => TProps

// @public (undocumented)
export type SelectorFactory<S, TProps, TOwnProps, TFactoryOptions> = (
  dispatch: Dispatch<Action>,
  factoryOptions: TFactoryOptions,
) => Selector<S, TProps, TOwnProps>

// @public (undocumented)
export function shallowEqual(objA: any, objB: any): boolean

// @public
export type Shared<InjectedProps, DecorationTargetProps> = {
  [P in Extract<
    keyof InjectedProps,
    keyof DecorationTargetProps
  >]?: InjectedProps[P] extends DecorationTargetProps[P]
    ? DecorationTargetProps[P]
    : never
}

// @public
export interface TypedUseSelectorHook<TState> {
  // (undocumented)
  <TSelected>(
    selector: (state: TState) => TSelected,
    equalityFn?: (left: TSelected, right: TSelected) => boolean,
  ): TSelected
}

// @public
export const useDispatch: () => Dispatch<AnyAction>

// @public
export const useSelector: <TState = DefaultRootState, Selected = unknown>(
  selector: (state: TState) => Selected,
  equalityFn?: EqualityFn<Selected> | undefined,
) => Selected

// @public
export const useStore: () => Store<any, AnyAction>

// (No @packageDocumentation comment for this package)