export type Segment = { name: string type: 'dir' | 'param' } export type Transform = { toState: (value: string) => T toPath: (value: T) => string } export type Route = { raw: string segments: Segment[] transform?: { [key: string]: Transform } } // eslint-disable-next-line no-use-before-define export type RouteChildren = Node[] | ((state: Record) => Node[]) export type Node = { route: Route scope?: string transform?: { [key: string]: Transform } children: RouteChildren } export type Router = Node & { _isRoute: boolean encode: (state: Record) => string decode: (path: string) => Record | null isNotFound: (path: string) => boolean getBasePath: () => string getRedirectBase: (pathname: string) => string | null isRoot: (path: string) => boolean } export type MatchResult = { nodes: Node[] missing: string[] remaining: string[] }