UNPKG

1.37 kBTypeScriptView Raw
1import { ReactElement } from 'react';
2import { Resolver } from '@shopify/async';
3import { IfAllOptionalKeys } from '@shopify/useful-types';
4export declare enum AssetTiming {
5 None = 1,
6 NextPage = 2,
7 CurrentPage = 3,
8 Immediate = 4
9}
10export interface AsyncComponentType<T, Props extends object, PreloadOptions extends object, PrefetchOptions extends object, KeepFreshOptions extends object> {
11 readonly resolver: Resolver<T>;
12 (props: Props): ReactElement<Props>;
13 Preload(props: PreloadOptions): React.ReactElement<{}> | null;
14 Prefetch(props: PrefetchOptions): React.ReactElement<{}> | null;
15 KeepFresh(props: KeepFreshOptions): React.ReactElement<{}> | null;
16 usePreload(...props: IfAllOptionalKeys<PreloadOptions, [PreloadOptions?], [PreloadOptions]>): () => void;
17 usePrefetch(...props: IfAllOptionalKeys<PrefetchOptions, [PrefetchOptions?], [PrefetchOptions]>): () => void;
18 useKeepFresh(...props: IfAllOptionalKeys<KeepFreshOptions, [KeepFreshOptions?], [KeepFreshOptions]>): () => void;
19}
20export declare type PreloadOptions<T> = T extends AsyncComponentType<any, any, infer U, any, any> ? U : never;
21export declare type PrefetchOptions<T> = T extends AsyncComponentType<any, any, infer U, any, any> ? U : never;
22export declare type KeepFreshOptions<T> = T extends AsyncComponentType<any, any, infer U, any, any> ? U : never;