Sha256: 2ee99175bd5c647d0bfda0cf8c6cc4500d6f0c71f1fa37ec1fb84f51a738e66c

Contents?: true

Size: 1.2 KB

Versions: 81

Compression:

Stored size: 1.2 KB

Contents

/*
 * Foundation: useLocation and paths
 */

export type Path = string;

// the base useLocation hook type. Any custom hook (including the
// default one) should inherit from it.
export type BaseLocationHook = (
  ...args: any[]
) => [Path, (path: Path, ...args: any[]) => any];

/*
 * Utility types that operate on hook
 */

// Returns the type of the location tuple of the given hook.
export type HookReturnValue<H extends BaseLocationHook> = ReturnType<H>;

// Returns the type of the navigation options that hook's push function accepts.
export type HookNavigationOptions<H extends BaseLocationHook> = HookReturnValue<
  H
>[1] extends (path: Path, options: infer R, ...rest: any[]) => any
  ? R extends { [k: string]: any }
    ? R
    : {}
  : {};

/*
 * Default `useLocation`
 */

// The type of the default `useLocation` hook that wouter uses.
// It operates on current URL using History API, supports base path and can
// navigate with `pushState` or `replaceState`.
export type LocationHook = (options?: {
  base?: Path;
}) => [Path, (to: Path, options?: { replace?: boolean }) => void];

declare const useLocation: LocationHook;
export default useLocation;

export type LocationTuple = HookReturnValue<LocationHook>;

Version data entries

81 entries across 81 versions & 1 rubygems

Version Path
isomorfeus-preact-10.9.0 node_modules/wouter-preact/use-location.d.ts
isomorfeus-preact-10.8.2 node_modules/wouter-preact/use-location.d.ts
isomorfeus-preact-10.8.1 node_modules/wouter-preact/use-location.d.ts
isomorfeus-preact-10.8.0 node_modules/wouter-preact/use-location.d.ts
isomorfeus-preact-10.7.3 node_modules/wouter-preact/use-location.d.ts
isomorfeus-preact-10.7.2 node_modules/wouter-preact/use-location.d.ts
isomorfeus-preact-10.7.1 node_modules/wouter-preact/use-location.d.ts
isomorfeus-preact-10.7.0 node_modules/wouter-preact/use-location.d.ts
isomorfeus-preact-10.6.62 node_modules/wouter-preact/use-location.d.ts
isomorfeus-preact-10.6.61 node_modules/wouter-preact/use-location.d.ts
isomorfeus-preact-10.6.60 node_modules/wouter-preact/use-location.d.ts
isomorfeus-preact-10.6.59 node_modules/wouter-preact/use-location.d.ts
isomorfeus-preact-10.6.58 node_modules/wouter-preact/use-location.d.ts
isomorfeus-preact-10.6.57 node_modules/wouter-preact/use-location.d.ts
isomorfeus-preact-10.6.56 node_modules/wouter-preact/use-location.d.ts
isomorfeus-preact-10.6.55 node_modules/wouter-preact/use-location.d.ts
isomorfeus-preact-10.6.54 node_modules/wouter-preact/use-location.d.ts
isomorfeus-preact-10.6.53 node_modules/wouter-preact/use-location.d.ts
isomorfeus-preact-10.6.52 node_modules/wouter-preact/use-location.d.ts
isomorfeus-preact-10.6.51 node_modules/wouter-preact/use-location.d.ts