@tanstack/router-core 0.0.1-beta.157 → 0.0.1-beta.159

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1061,42 +1061,36 @@
1061
1061
  if (routeCursor) matchedRoutes.unshift(routeCursor);
1062
1062
  }
1063
1063
 
1064
- // Alright, by now we should have all of our
1065
- // matching routes and their param pairs, let's
1066
- // Turn them into actual `Match` objects and
1067
- // accumulate the params into a single params bag
1068
- let allParams = {};
1069
-
1070
1064
  // Existing matches are matches that are already loaded along with
1071
1065
  // pending matches that are still loading
1072
1066
 
1073
- const matches = matchedRoutes.map(route => {
1074
- let parsedParams;
1067
+ const parseErrors = matchedRoutes.map(route => {
1075
1068
  let parsedParamsError;
1076
- try {
1077
- parsedParams = route.options.parseParams?.(routeParams) ?? routeParams;
1078
- // (typeof route.options.parseParams === 'object' &&
1079
- // route.options.parseParams.parse
1080
- // ? route.options.parseParams.parse(routeParams)
1081
- // : (route.options.parseParams as any)?.(routeParams!)) ?? routeParams
1082
- } catch (err) {
1083
- parsedParamsError = new PathParamError(err.message, {
1084
- cause: err
1085
- });
1086
- if (opts?.throwOnError) {
1087
- throw parsedParamsError;
1069
+ if (route.options.parseParams) {
1070
+ try {
1071
+ const parsedParams = route.options.parseParams(routeParams);
1072
+ // Add the parsed params to the accumulated params bag
1073
+ Object.assign(routeParams, parsedParams);
1074
+ } catch (err) {
1075
+ parsedParamsError = new PathParamError(err.message, {
1076
+ cause: err
1077
+ });
1078
+ if (opts?.throwOnError) {
1079
+ throw parsedParamsError;
1080
+ }
1081
+ return parsedParamsError;
1088
1082
  }
1089
1083
  }
1090
-
1091
- // Add the parsed params to the accumulated params bag
1092
- Object.assign(allParams, parsedParams);
1093
- const interpolatedPath = interpolatePath(route.path, allParams);
1084
+ return;
1085
+ });
1086
+ const matches = matchedRoutes.map((route, index) => {
1087
+ const interpolatedPath = interpolatePath(route.path, routeParams);
1094
1088
  const key = route.options.key ? route.options.key({
1095
- params: allParams,
1089
+ params: routeParams,
1096
1090
  search: locationSearch
1097
1091
  }) ?? '' : '';
1098
1092
  const stringifiedKey = key ? JSON.stringify(key) : '';
1099
- const matchId = interpolatePath(route.id, allParams, true) + stringifiedKey;
1093
+ const matchId = interpolatePath(route.id, routeParams, true) + stringifiedKey;
1100
1094
 
1101
1095
  // Waste not, want not. If we already have a match for this route,
1102
1096
  // reuse it. This is important for layout routes, which might stick
@@ -1114,7 +1108,7 @@
1114
1108
  id: matchId,
1115
1109
  key: stringifiedKey,
1116
1110
  routeId: route.id,
1117
- params: allParams,
1111
+ params: routeParams,
1118
1112
  pathname: joinPaths([this.basepath, interpolatedPath]),
1119
1113
  updatedAt: Date.now(),
1120
1114
  invalidAt: Infinity,
@@ -1125,7 +1119,7 @@
1125
1119
  isFetching: false,
1126
1120
  invalid: false,
1127
1121
  error: undefined,
1128
- paramsError: parsedParamsError,
1122
+ paramsError: parseErrors[index],
1129
1123
  searchError: undefined,
1130
1124
  loaderData: undefined,
1131
1125
  loadPromise: Promise.resolve(),