| EXPERIMENTAL_RouteRecordNormalized_Matchable
| EXPERIMENTAL_RouteRecordNormalized_Group
+export function normalizeRouteRecord(
+ record: EXPERIMENTAL_RouteRecord_Group
+): EXPERIMENTAL_RouteRecordNormalized_Group
export function normalizeRouteRecord(
record: EXPERIMENTAL_RouteRecord_Matchable
-): EXPERIMENTAL_RouteRecordNormalized_Matchable {
+): EXPERIMENTAL_RouteRecordNormalized_Matchable
+export function normalizeRouteRecord(
+ record: EXPERIMENTAL_RouteRecord_Matchable | EXPERIMENTAL_RouteRecord_Group
+):
+ | EXPERIMENTAL_RouteRecordNormalized_Matchable
+ | EXPERIMENTAL_RouteRecordNormalized_Group {
// we can't define mods if we want to call defineProperty later
- const normalizedRecord: Omit<
- EXPERIMENTAL_RouteRecordNormalized_Matchable,
- 'mods'
- > = {
+ const normalizedRecord:
+ | Omit<EXPERIMENTAL_RouteRecordNormalized_Matchable, 'mods'>
+ | Omit<EXPERIMENTAL_RouteRecordNormalized_Group, 'mods'> = {
meta: {},
// must be defined as non enumerable because it contains modules
// mods: {},
value: {},
})
- return normalizedRecord as EXPERIMENTAL_RouteRecordNormalized_Matchable
+ return normalizedRecord as
+ | EXPERIMENTAL_RouteRecordNormalized_Matchable
+ | EXPERIMENTAL_RouteRecordNormalized_Group
}
// TODO: probably need some generic types
// }
const matchedRoute = resolver.resolve(
- // incompatible types
+ // FIXME: incompatible types
rawLocation as any,
- // incompatible `matched` requires casting
+ // FIXME: incompatible `matched` requires casting
currentLocation as any
)
const href = routerHistory.createHref(matchedRoute.fullPath)
const from = currentRoute.value
const data: HistoryState | undefined = (to as RouteLocationOptions).state
const force: boolean | undefined = (to as RouteLocationOptions).force
- const replace = (to as RouteLocationOptions).replace ?? _replace
+ const replace = targetLocation.replace ?? _replace
+ console.log({ replace })
const shouldRedirect = handleRedirectRecord(targetLocation)
const guards: Array<() => Promise<void>> = []
for (const record of matched) {
- if (__DEV__ && !record.components && !record.children.length) {
+ if (
+ __DEV__ &&
+ !record.components &&
+ // in the nex records, there is no children, only parents
+ record.children &&
+ !record.children.length
+ ) {
warn(
`Record with path "${record.path}" is either missing a "component(s)"` +
` or "children" property.`