Skip to content

Commit

Permalink
refactor(sanity): add Route* prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
mariuslundgard committed Oct 4, 2022
1 parent e68e742 commit e267849
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions packages/sanity/src/router/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {decodeParams, encodeParams} from './utils/paramsEncoding'
/**
* @public
*/
export type NodeOptions = {
export type RouteNodeOptions = {
path?: string
children?: RouteChildren
transform?: {
Expand All @@ -22,8 +22,8 @@ export type NodeOptions = {
*/
export const route: {
create: (
routeOrOpts: NodeOptions | string,
childrenOrOpts?: NodeOptions | RouteChildren | null,
routeOrOpts: RouteNodeOptions | string,
childrenOrOpts?: RouteNodeOptions | RouteChildren | null,
children?: Router | RouteChildren
) => Router
intents: (base: string) => Router
Expand All @@ -37,16 +37,16 @@ function normalizeChildren(children: any): RouteChildren {
return children ? [children] : []
}

function isRoute(val?: NodeOptions | Router | RouteChildren) {
function isRoute(val?: RouteNodeOptions | Router | RouteChildren) {
return val && '_isRoute' in val
}

function normalizeArgs(...args: any[]): NodeOptions
function normalizeArgs(...args: any[]): RouteNodeOptions
function normalizeArgs(
path: string | NodeOptions,
childrenOrOpts?: NodeOptions | Router | RouteChildren,
path: string | RouteNodeOptions,
childrenOrOpts?: RouteNodeOptions | Router | RouteChildren,
children?: Router | RouteChildren
): NodeOptions {
): RouteNodeOptions {
if (typeof path === 'object') {
return path
}
Expand All @@ -67,8 +67,8 @@ function normalizeArgs(
}

function createRoute(
routeOrOpts: NodeOptions | string,
childrenOrOpts?: NodeOptions | RouteChildren | null,
routeOrOpts: RouteNodeOptions | string,
childrenOrOpts?: RouteNodeOptions | RouteChildren | null,
children?: Router | RouteChildren
): Router {
return createNode(normalizeArgs(routeOrOpts, childrenOrOpts, children))
Expand Down Expand Up @@ -122,7 +122,7 @@ function isRoot(pathname: string): boolean {
return pathname.split('/').every((segment) => !segment)
}

function createNode(options: NodeOptions): Router {
function createNode(options: RouteNodeOptions): Router {
const {path, scope, transform, children} = options

if (!path) {
Expand Down

0 comments on commit e267849

Please sign in to comment.