Skip to content

Conversation

schiller-manuel
Copy link
Contributor

@schiller-manuel schiller-manuel commented Oct 14, 2025

fixes #5212

Summary by CodeRabbit

  • New Features
    • Added parameterized API endpoints:
      • GET /api/params/:foo — returns a greeting including the provided foo value.
      • GET /api/params/:foo/:bar — returns a greeting including the provided foo and bar values.
    • Supports nested routing for these endpoints, enabling clean URL structures with multiple path parameters.
    • Improves consistency of parameter handling across parent and child routes for more reliable server responses.

Copy link
Contributor

coderabbitai bot commented Oct 14, 2025

Walkthrough

Adds two new server routes (/api/params/$foo and /api/params/$foo/$bar) with generated route tree updates. Refactors server route type generics to use TFullPath and TParams and switches param resolution to ResolveAllParamsFromParent. Adjusts type signatures across serverRoute.ts and updates a related type annotation in createStartHandler.ts.

Changes

Cohort / File(s) Summary
Generated route tree updates
e2e/react-start/server-routes/src/routeTree.gen.ts
Imports and registers new routes for /api/params/$foo and /api/params/$foo/$bar; augments route type maps, module declarations, and children compositions; updates routeTree construction accordingly.
New API routes
e2e/react-start/server-routes/src/routes/api/params/$foo/route.ts, e2e/react-start/server-routes/src/routes/api/params/$foo/$bar.ts
Adds file-based server routes with GET handlers returning text responses using params.foo and params.bar.
Server route type refactor
packages/start-client-core/src/serverRoute.ts
Replaces ResolveParams with ResolveAllParamsFromParent; introduces TFullPath and explicit TParams across public types and handler contexts; adjusts generics and handler/request param typings.
Start handler typing adjustment
packages/start-server-core/src/createStartHandler.ts
Extends RouteMethodHandlerFn generic arity in handlerToMiddleware type annotation; no runtime changes.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Client
  participant Router as React Router (Server)
  participant Matcher as Route Matcher
  participant Handler as Route Handler (GET)
  note over Router,Handler: Param resolution now uses ResolveAllParamsFromParent

  Client->>Router: HTTP GET /api/params/$foo/$bar
  Router->>Matcher: Match route by fullPath
  Matcher-->>Router: Matched route + parent chain
  Router->>Handler: Invoke GET with ctx { params: resolved from parents }
  Handler-->>Router: Response("hello, foo and bar")
  Router-->>Client: HTTP 200 text/plain
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Suggested labels

package: start-storage-context

Poem

In burrows of routes where parameters play,
I sniffed out $foo, then $bar led the way.
With paths made full and typings aligned,
Parents share secrets the children can find.
Tap-tap my paws—requests hop through—
Hello to you, and hello to foo! 🐇✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title “fix: parent param types in server routes” clearly and concisely summarizes the primary change in the pull request, which is the correction of how parent route parameters are typed in server route handlers, and does so without any extraneous details or noise. It directly references the nature of the fix and is specific enough for a teammate to understand the main change at a glance.
Linked Issues Check ✅ Passed The code changes directly address the incorrect params type generation described in issue #5212 by introducing a new generic TParams and replacing ResolveParams with ResolveAllParamsFromParent to ensure that both parent and current route parameters are correctly resolved, and the updated type signatures align with the expected behavior of having params.param typed as string in nested server handlers. The addition of example nested routes for /api/params/$foo and /api/params/$foo/$bar further validates that the param types flow correctly without errors.
Out of Scope Changes Check ✅ Passed All modifications in this pull request are focused on improving the parameter typing system and updating the generated route definitions to support nested parameter routes, with no unrelated or extraneous changes outside the scope of fixing parent param types. The e2e route additions serve to demonstrate and verify the correct behavior of the updated typing logic, and the minor type extension in createStartHandler is consistent with the broader type system adjustments.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-5212

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

nx-cloud bot commented Oct 14, 2025

View your CI Pipeline Execution ↗ for commit 2b52abe

Command Status Duration Result
nx affected --targets=test:eslint,test:unit,tes... ✅ Succeeded 4m 31s View ↗
nx run-many --target=build --exclude=examples/*... ✅ Succeeded 28s View ↗

☁️ Nx Cloud last updated this comment at 2025-10-14 21:52:12 UTC

Copy link

pkg-pr-new bot commented Oct 14, 2025

More templates

@tanstack/arktype-adapter

npm i https://pkg.pr.new/TanStack/router/@tanstack/arktype-adapter@5482

@tanstack/directive-functions-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/directive-functions-plugin@5482

@tanstack/eslint-plugin-router

npm i https://pkg.pr.new/TanStack/router/@tanstack/eslint-plugin-router@5482

@tanstack/history

npm i https://pkg.pr.new/TanStack/router/@tanstack/history@5482

@tanstack/nitro-v2-vite-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/nitro-v2-vite-plugin@5482

@tanstack/react-router

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router@5482

@tanstack/react-router-devtools

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router-devtools@5482

@tanstack/react-router-ssr-query

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router-ssr-query@5482

@tanstack/react-start

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start@5482

@tanstack/react-start-client

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start-client@5482

@tanstack/react-start-server

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start-server@5482

@tanstack/router-cli

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-cli@5482

@tanstack/router-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-core@5482

@tanstack/router-devtools

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-devtools@5482

@tanstack/router-devtools-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-devtools-core@5482

@tanstack/router-generator

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-generator@5482

@tanstack/router-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-plugin@5482

@tanstack/router-ssr-query-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-ssr-query-core@5482

@tanstack/router-utils

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-utils@5482

@tanstack/router-vite-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-vite-plugin@5482

@tanstack/server-functions-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/server-functions-plugin@5482

@tanstack/solid-router

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router@5482

@tanstack/solid-router-devtools

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router-devtools@5482

@tanstack/solid-start

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start@5482

@tanstack/solid-start-client

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start-client@5482

@tanstack/solid-start-server

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start-server@5482

@tanstack/start-client-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-client-core@5482

@tanstack/start-plugin-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-plugin-core@5482

@tanstack/start-server-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-server-core@5482

@tanstack/start-static-server-functions

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-static-server-functions@5482

@tanstack/start-storage-context

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-storage-context@5482

@tanstack/valibot-adapter

npm i https://pkg.pr.new/TanStack/router/@tanstack/valibot-adapter@5482

@tanstack/virtual-file-routes

npm i https://pkg.pr.new/TanStack/router/@tanstack/virtual-file-routes@5482

@tanstack/zod-adapter

npm i https://pkg.pr.new/TanStack/router/@tanstack/zod-adapter@5482

commit: 2b52abe

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
packages/start-client-core/src/serverRoute.ts (2)

134-186: Double-check TPath vs TFullPath handoff

RouteServerOptions expects TFullPath, but FilebaseRouteOptionsInterface passes TPath into it. If router-core’s FilebaseRouteOptionsInterface exposes both TPath and TFullPath generics, consider passing TFullPath here; otherwise, confirm that TPath indeed represents the full path at this point.


115-132: Prefer unknown over any in conditional inference points

Using unknown instead of any in ExtractHandlersContext preserves type safety without losing inference.

Apply if desired:

-) => CustomHandlerFunctionsRecord<
-  any,
-  any,
-  any,
-  any,
-  any,
-  any,
-  infer TServerContext
->
+) => CustomHandlerFunctionsRecord<
+  unknown,
+  unknown,
+  unknown,
+  unknown,
+  unknown,
+  unknown,
+  infer TServerContext
+>
@@
-        RouteMethodHandler<any, any, any, any, any, any, infer TServerContext>
+        RouteMethodHandler<unknown, unknown, unknown, unknown, unknown, unknown, infer TServerContext>
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6cc67e5 and 2b52abe.

📒 Files selected for processing (5)
  • e2e/react-start/server-routes/src/routeTree.gen.ts (3 hunks)
  • e2e/react-start/server-routes/src/routes/api/params/$foo/$bar.ts (1 hunks)
  • e2e/react-start/server-routes/src/routes/api/params/$foo/route.ts (1 hunks)
  • packages/start-client-core/src/serverRoute.ts (18 hunks)
  • packages/start-server-core/src/createStartHandler.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Use TypeScript in strict mode with extensive type safety across the codebase

Files:

  • packages/start-server-core/src/createStartHandler.ts
  • e2e/react-start/server-routes/src/routes/api/params/$foo/$bar.ts
  • e2e/react-start/server-routes/src/routes/api/params/$foo/route.ts
  • packages/start-client-core/src/serverRoute.ts
  • e2e/react-start/server-routes/src/routeTree.gen.ts
packages/{*-start,start-*}/**

📄 CodeRabbit inference engine (AGENTS.md)

Name and place Start framework packages under packages/-start/ or packages/start-/

Files:

  • packages/start-server-core/src/createStartHandler.ts
  • packages/start-client-core/src/serverRoute.ts
**/src/routes/**

📄 CodeRabbit inference engine (AGENTS.md)

Place file-based routes under src/routes/ directories

Files:

  • e2e/react-start/server-routes/src/routes/api/params/$foo/$bar.ts
  • e2e/react-start/server-routes/src/routes/api/params/$foo/route.ts
e2e/**

📄 CodeRabbit inference engine (AGENTS.md)

Store end-to-end tests under the e2e/ directory

Files:

  • e2e/react-start/server-routes/src/routes/api/params/$foo/$bar.ts
  • e2e/react-start/server-routes/src/routes/api/params/$foo/route.ts
  • e2e/react-start/server-routes/src/routeTree.gen.ts
🧬 Code graph analysis (4)
packages/start-server-core/src/createStartHandler.ts (1)
packages/start-client-core/src/serverRoute.ts (1)
  • RouteMethodHandlerFn (437-456)
e2e/react-start/server-routes/src/routes/api/params/$foo/$bar.ts (1)
e2e/react-start/server-routes/src/routes/api/params/$foo/route.ts (1)
  • Route (3-11)
e2e/react-start/server-routes/src/routes/api/params/$foo/route.ts (1)
e2e/react-start/server-routes/src/routes/api/params/$foo/$bar.ts (1)
  • Route (3-11)
e2e/react-start/server-routes/src/routeTree.gen.ts (2)
e2e/react-start/server-functions/src/routeTree.gen.ts (5)
  • FileRoutesByFullPath (149-172)
  • FileRoutesByTo (173-196)
  • FileRoutesById (197-221)
  • FileRouteTypes (222-296)
  • RootRouteChildren (297-320)
examples/react/start-basic/src/routeTree.gen.ts (5)
  • FileRoutesByFullPath (117-133)
  • FileRoutesByTo (134-148)
  • FileRoutesById (149-168)
  • FileRouteTypes (169-222)
  • RootRouteChildren (223-233)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Test
  • GitHub Check: Preview
🔇 Additional comments (5)
e2e/react-start/server-routes/src/routes/api/params/$foo/route.ts (1)

3-11: LGTM: parent param is consumed in handler

Handler reads params.foo as intended; good coverage for the fix path.

e2e/react-start/server-routes/src/routes/api/params/$foo/$bar.ts (1)

3-11: LGTM: nested param merging is exercised

Handler reads both params.foo and params.bar, matching the new ResolveAllParamsFromParent behavior.

e2e/react-start/server-routes/src/routeTree.gen.ts (1)

34-44: Generated route wiring looks consistent

  • ApiParamsFooRouteRoute at /api/params/$foo under root.
  • ApiParamsFooBarRoute with id/path '/$bar' under ApiParamsFooRouteRoute and fullPath '/api/params/$foo/$bar'.
  • Public typings updated (fullPaths, to, id, RootRouteChildren).

No issues spotted.

Also applies to: 45-66, 121-134, 146-154

packages/start-client-core/src/serverRoute.ts (1)

484-486: Param typing fix approved; ResolveParams no longer used
Confirm TS compilation and that route handlers can access merged params (e.g., params.foo/params.bar) without errors.

packages/start-server-core/src/createStartHandler.ts (1)

455-456: Generic arity update is correct
All RouteMethodHandlerFn<> usages—including those in serverRoute.ts—now use seven type parameters; no further changes required.

@schiller-manuel schiller-manuel merged commit 8dd0cc5 into main Oct 14, 2025
6 checks passed
@schiller-manuel schiller-manuel deleted the fix-5212 branch October 14, 2025 21:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect params type generation

1 participant