RouteLocationResolved,
RouteMap,
RouteRecordNameGeneric,
+ RouteRecordRedirectOption,
} from '../typed-routes'
import {
Lazy,
// linkInactiveClass?: string
}
-// TODO: non matchable and parent
/**
* Internal type for common properties among all kind of {@link RouteRecordRaw}.
*/
* before any navigation guard and triggers a new navigation with the new
* target location.
*/
- // redirect?: RouteRecordRedirectOption;
+ redirect?: RouteRecordRedirectOption
// TODO:
/**
*/
meta?: RouteMeta
- // TODO:
- /**
- * Array of nested routes.
- */
- // children?: RouteRecordRaw[]
-
/**
* Components to display when the URL matches this route. Allow using named views.
*/
components: Record<string, RawRouteComponent>
parent?: EXPERIMENTAL_RouteRecordNormalized | null
-
- redirect?: never
}
export interface EXPERIMENTAL_RouteRecord_Group
components?: Record<string, RawRouteComponent>
parent?: EXPERIMENTAL_RouteRecordNormalized | null
-
- // TODO:
- // redirect?: something
}
export type EXPERIMENTAL_RouteRecordRaw =
parent: EXPERIMENTAL_RouteRecordNormalized | null
- // TODO:
- // redirect?: unknown
-
components: Record<string, RawRouteComponent>
}
) {
for (const record of routeRecords) {
main.meta = { ...main.meta, ...record.meta }
+ main.props = { ...main.props, ...record.props }
}
return main
}
return !!resolver.getRecord(name)
}
- // TODO: replace usage with resolver.resolve()
-
// NOTE: to support multiple overloads
type TRecord = EXPERIMENTAL_RouteRecordNormalized
type _resolveArgs =
function resolve(
...[to, currentLocation]: _resolveArgs
): RouteLocationResolved {
- // const resolve: Router['resolve'] = (rawLocation: RouteLocationRaw, currentLocation) => {
- // const objectLocation = routerLocationAsObject(rawLocation)
- // we create a copy to modify it later
- // TODO: in the experimental version, allow configuring this
- currentLocation =
- // TODO: || currentRoute.value never evaluated
- currentLocation && assign({}, currentLocation || currentRoute.value)
- // currentLocation = assign({}, currentLocation || currentRoute.value)
-
- // FIXME: should this be achieved by matchers?
- // remove any nullish param
- // if ('params' in rawLocation) {
- // const targetParams = assign({}, rawLocation.params)
- // for (const key in targetParams) {
- // if (targetParams[key] == null) {
- // delete targetParams[key]
- // }
- // }
- // rawLocation.params = targetParams
- // }
-
const matchedRoute = resolver.resolve(
// @ts-expect-error FIXME: incompatible types
to,
): RouteLocationRaw | void {
const redirect = to.matched.at(-1)?.redirect
if (redirect) {
- return resolve(
+ return resolver.resolve(
// @ts-expect-error: TODO: allow redirect to return the first argument of resolve or a tuple consisting of the arguments?
typeof redirect === 'function' ? redirect(to, from) : redirect,
from