// Type definitions for @loadable/component 5.13 // Project: https://github.com/smooth-code/loadable-components // Definitions by: Martynas KadiĊĦa // Daniel Playfair Cal // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 import * as React from "react"; export interface DefaultImportedComponent { default: React.ComponentType; } export type DefaultComponent = React.ComponentType | DefaultImportedComponent; /** * Synchronous function that returns the component from the * imported module. * * The default works with default exports, both CommonJS or ESM */ export type ComponentResolver> = ( module: Module, props: Props, ) => React.ComponentType; export interface OptionsWithoutResolver { cacheKey?(props: Props): any; fallback?: JSX.Element | undefined; ssr?: boolean | undefined; } export interface Options> extends OptionsWithoutResolver { resolveComponent?: ComponentResolver | undefined; } export interface OptionsWithResolver> extends OptionsWithoutResolver { resolveComponent: ComponentResolver; } export interface LoadableReadyOptions { namespace?: string | undefined; } export interface LoadableComponentMethods { preload(props?: Props): void; load(props?: Props): Promise>; } export interface ExtraComponentProps { fallback?: JSX.Element | undefined; } export type LoadableComponent = & React.ComponentType & LoadableComponentMethods; export interface ExtraClassComponentProps extends ExtraComponentProps { ref?: React.LegacyRef> | undefined; } export type LoadableClassComponent = & React.ComponentType< React.ComponentProps & ExtraClassComponentProps > & LoadableComponentMethods>; export type LoadableLibrary = & React.ComponentType<{ fallback?: JSX.Element | undefined; children?: ((module: Module) => React.ReactNode) | undefined; ref?: React.Ref | undefined; }> & Module & LoadableComponentMethods; declare function lib( loadFn: (props: Props) => Promise, options?: OptionsWithoutResolver, ): LoadableLibrary; declare function loadableFunc>( loadFn: (props: Props) => Promise, options: OptionsWithResolver, ): LoadableComponent; declare function loadableFunc( loadFn: (props: Props) => Promise>, options?: OptionsWithoutResolver, ): LoadableComponent; declare function loadableFunc>( loadFn: (props: React.ComponentProps) => Promise, options?: Options, Component>, ): LoadableClassComponent; declare const loadable: typeof loadableFunc & { lib: typeof lib }; export default loadable; export namespace lazy { function lib(loadFn: (props: object) => Promise): LoadableLibrary; } export function lazy(loadFn: (props: Props) => Promise>): LoadableComponent; export function loadableReady(done?: () => any, options?: LoadableReadyOptions): Promise;