web: update the type names for routes.
While writing up the commit message for the previous commit, I realized that I didn't really like the typenames as they're outlaid in `routeUtils`. This is much more explicit, describing the four types of routes we have: ListRoute, ViewRoute, InternalRedirect, ExternalRedirect.
This commit is contained in:
@ -3,13 +3,17 @@ import { P, match } from "ts-pattern";
|
|||||||
|
|
||||||
import { TemplateResult } from "lit";
|
import { TemplateResult } from "lit";
|
||||||
|
|
||||||
type RouteInvoke =
|
type ListRoute = () => Promise<TemplateResult<1>>;
|
||||||
| ((_1: RouteArgs) => Promise<TemplateResult<1>>)
|
type ViewRoute = (_1: RouteArgs) => Promise<TemplateResult<1>>;
|
||||||
| (() => Promise<TemplateResult<1>>);
|
type InternalRedirect = string;
|
||||||
|
type ExternalRedirect = [string, boolean];
|
||||||
|
|
||||||
type _RawRedirect = [string, string | [string, boolean]];
|
type RouteInvoke = ViewRoute | ListRoute;
|
||||||
type _RawRoute = [string, RouteInvoke];
|
|
||||||
export type RawRoute = _RawRoute | _RawRedirect;
|
type RedirectRoute = [string, InternalRedirect | ExternalRedirect];
|
||||||
|
type PageRoute = [string, RouteInvoke];
|
||||||
|
|
||||||
|
export type RawRoute = PageRoute | RedirectRoute;
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
const isLoader = (v: any): v is RouteInvoke => typeof v === "function";
|
const isLoader = (v: any): v is RouteInvoke => typeof v === "function";
|
||||||
|
Reference in New Issue
Block a user