xref: /expo/packages/expo-router/src/types.ts (revision 8ec56fca)
1import type { Href } from './link/href';
2
3// TODO: Use the global type
4export interface RequireContext {
5  /** Return the keys that can be resolved. */
6  keys(): string[];
7  (id: string): any;
8  <T>(id: string): T;
9  /** **Unimplemented:** Return the module identifier for a user request. */
10  resolve(id: string): string;
11  /** **Unimplemented:** Readable identifier for the context module. */
12  id: string;
13}
14
15/** The list of input keys will become optional, everything else will remain the same. */
16export type PickPartial<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
17
18export type Router = {
19  /** Navigate to the provided href. */
20  push: (href: Href) => void;
21  /** Navigate to route without appending to the history. */
22  replace: (href: Href) => void;
23  /** Go back in the history. */
24  back: () => void;
25  /** If there's history that supports invoking the `back` function. */
26  canGoBack: () => boolean;
27  /** Update the current route query params. */
28  setParams: (params?: Record<string, string>) => void;
29};
30