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

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.
@@ -966,42 +966,36 @@ class Router {
966
966
  if (routeCursor) matchedRoutes.unshift(routeCursor);
967
967
  }
968
968
 
969
- // Alright, by now we should have all of our
970
- // matching routes and their param pairs, let's
971
- // Turn them into actual `Match` objects and
972
- // accumulate the params into a single params bag
973
- let allParams = {};
974
-
975
969
  // Existing matches are matches that are already loaded along with
976
970
  // pending matches that are still loading
977
971
 
978
- const matches = matchedRoutes.map(route => {
979
- let parsedParams;
972
+ const parseErrors = matchedRoutes.map(route => {
980
973
  let parsedParamsError;
981
- try {
982
- parsedParams = route.options.parseParams?.(routeParams) ?? routeParams;
983
- // (typeof route.options.parseParams === 'object' &&
984
- // route.options.parseParams.parse
985
- // ? route.options.parseParams.parse(routeParams)
986
- // : (route.options.parseParams as any)?.(routeParams!)) ?? routeParams
987
- } catch (err) {
988
- parsedParamsError = new PathParamError(err.message, {
989
- cause: err
990
- });
991
- if (opts?.throwOnError) {
992
- throw parsedParamsError;
974
+ if (route.options.parseParams) {
975
+ try {
976
+ const parsedParams = route.options.parseParams(routeParams);
977
+ // Add the parsed params to the accumulated params bag
978
+ Object.assign(routeParams, parsedParams);
979
+ } catch (err) {
980
+ parsedParamsError = new PathParamError(err.message, {
981
+ cause: err
982
+ });
983
+ if (opts?.throwOnError) {
984
+ throw parsedParamsError;
985
+ }
986
+ return parsedParamsError;
993
987
  }
994
988
  }
995
-
996
- // Add the parsed params to the accumulated params bag
997
- Object.assign(allParams, parsedParams);
998
- const interpolatedPath = interpolatePath(route.path, allParams);
989
+ return;
990
+ });
991
+ const matches = matchedRoutes.map((route, index) => {
992
+ const interpolatedPath = interpolatePath(route.path, routeParams);
999
993
  const key = route.options.key ? route.options.key({
1000
- params: allParams,
994
+ params: routeParams,
1001
995
  search: locationSearch
1002
996
  }) ?? '' : '';
1003
997
  const stringifiedKey = key ? JSON.stringify(key) : '';
1004
- const matchId = interpolatePath(route.id, allParams, true) + stringifiedKey;
998
+ const matchId = interpolatePath(route.id, routeParams, true) + stringifiedKey;
1005
999
 
1006
1000
  // Waste not, want not. If we already have a match for this route,
1007
1001
  // reuse it. This is important for layout routes, which might stick
@@ -1019,7 +1013,7 @@ class Router {
1019
1013
  id: matchId,
1020
1014
  key: stringifiedKey,
1021
1015
  routeId: route.id,
1022
- params: allParams,
1016
+ params: routeParams,
1023
1017
  pathname: joinPaths([this.basepath, interpolatedPath]),
1024
1018
  updatedAt: Date.now(),
1025
1019
  invalidAt: Infinity,
@@ -1030,7 +1024,7 @@ class Router {
1030
1024
  isFetching: false,
1031
1025
  invalid: false,
1032
1026
  error: undefined,
1033
- paramsError: parsedParamsError,
1027
+ paramsError: parseErrors[index],
1034
1028
  searchError: undefined,
1035
1029
  loaderData: undefined,
1036
1030
  loadPromise: Promise.resolve(),