Skip to content

fix: server middleware type in solid-router#7260

Merged
birkskyum merged 5 commits intomainfrom
fix/issue-7092
Apr 25, 2026
Merged

fix: server middleware type in solid-router#7260
birkskyum merged 5 commits intomainfrom
fix/issue-7092

Conversation

@brenelz
Copy link
Copy Markdown
Contributor

@brenelz brenelz commented Apr 25, 2026

Closes #7092

Summary by CodeRabbit

  • Bug Fixes

    • Fixed server middleware type handling for file-based routes so middleware configuration is recognized and inferred correctly.
  • Tests

    • Added type-level tests to validate middleware configuration and inference for file routes.
  • Chores

    • Added changeset metadata to document the fix and mark a patch release.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 25, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adjusts TypeScript typing for file-route middleware inference by making TMiddlewares a const generic, adds a type-level test ensuring server.middleware context is propagated for file routes, and adds a changeset marking @tanstack/solid-router for a patch release fixing server middleware types.

Changes

Cohort / File(s) Summary
Changeset Metadata
​.changeset/curvy-chairs-study.md
Adds a changeset for @tanstack/solid-router (patch) with a short changelog noting a server middleware type fix.
FileRoute Generic
packages/solid-router/src/fileRoute.ts
Updates FileRoute.createRoute generics: TMiddlewares changed to a const type parameter (const TMiddlewares = unknown) to alter TypeScript inference behavior for middleware.
Type-Level Tests
packages/solid-router/tests/fileRoute.test-d.tsx
Adds module augmentation to accept server.middleware on file route options and a Vitest type-level test verifying middleware inference yields the expected readonly middleware tuple and context propagation.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

"I hopped through types with nimble paws,
consts and middleware fixed their flaws,
A tiny tweak, a joyful cheer,
Context flows true — the path is clear! 🐇✨"

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title 'fix: server middleware type in solid-router' directly corresponds to the main change: fixing incorrect type inference of server middleware context in Solid Router.
Linked Issues check ✅ Passed The PR addresses issue #7092 by implementing type-level support for server middleware in Solid Router's FileRoute, fixing the incorrect undefined typing of context returned from server middleware.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing server middleware typing in Solid Router: changelog entry, const type parameter adjustment, and type test for middleware inference.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/issue-7092

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@nx-cloud
Copy link
Copy Markdown
Contributor

nx-cloud Bot commented Apr 25, 2026

View your CI Pipeline Execution ↗ for commit bc40c09

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

☁️ Nx Cloud last updated this comment at 2026-04-25 17:03:02 UTC

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 25, 2026

🚀 Changeset Version Preview

1 package(s) bumped directly, 3 bumped as dependents.

🟩 Patch bumps

Package Version Reason
@tanstack/solid-router 1.168.21 → 1.168.22 Changeset
@tanstack/solid-start 1.167.43 → 1.167.44 Dependent
@tanstack/solid-start-client 1.166.38 → 1.166.39 Dependent
@tanstack/solid-start-server 1.166.39 → 1.166.40 Dependent

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 25, 2026

Bundle Size Benchmarks

  • Commit: d20c87813559
  • Measured at: 2026-04-25T17:03:47.009Z
  • Baseline source: history:d20c87813559
  • Dashboard: bundle-size history
Scenario Current (gzip) Delta vs baseline Raw Brotli Trend
react-router.minimal 87.35 KiB 0 B (0.00%) 274.60 KiB 75.97 KiB ▅▅▅▅▅▅▅▅▅▅▅
react-router.full 90.77 KiB 0 B (0.00%) 286.11 KiB 78.90 KiB ▁▁▁▁▁▁█████
solid-router.minimal 35.55 KiB 0 B (0.00%) 106.71 KiB 31.96 KiB ▅▅▅▅▅▅▅▅▅▅▅
solid-router.full 40.25 KiB 0 B (0.00%) 120.79 KiB 36.11 KiB ▁▁▁▁▁▁▆▆▆▆█
vue-router.minimal 53.30 KiB 0 B (0.00%) 152.01 KiB 47.88 KiB ▅▅▅▅▅▅▅▅▅▅▅
vue-router.full 58.44 KiB 0 B (0.00%) 168.19 KiB 52.34 KiB ▁▁▁▁▁▁█████
react-start.minimal 101.92 KiB 0 B (0.00%) 322.77 KiB 88.18 KiB ▁▁▁▁▁▁█████
react-start.full 105.35 KiB 0 B (0.00%) 333.10 KiB 91.02 KiB ▁▁▁▁▁▁█████
react-start.rsbuild.minimal 101.43 KiB 0 B (0.00%) 325.62 KiB 87.12 KiB ▁██
react-start.rsbuild.full 104.74 KiB 0 B (0.00%) 336.31 KiB 89.93 KiB ▅▅▅
solid-start.minimal 49.54 KiB 0 B (0.00%) 152.54 KiB 43.67 KiB ▁▁▁▁▁▁█████
solid-start.full 55.30 KiB 0 B (0.00%) 169.31 KiB 48.61 KiB ▁▁▁▁▁▁▆▆▆▆█

Trend sparkline is historical gzip bytes ending with this PR measurement; lower is better.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Apr 25, 2026

More templates

@tanstack/arktype-adapter

npm i https://pkg.pr.new/@tanstack/arktype-adapter@7260

@tanstack/eslint-plugin-router

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

@tanstack/eslint-plugin-start

npm i https://pkg.pr.new/@tanstack/eslint-plugin-start@7260

@tanstack/history

npm i https://pkg.pr.new/@tanstack/history@7260

@tanstack/nitro-v2-vite-plugin

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

@tanstack/react-router

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

@tanstack/react-router-devtools

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

@tanstack/react-router-ssr-query

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

@tanstack/react-start

npm i https://pkg.pr.new/@tanstack/react-start@7260

@tanstack/react-start-client

npm i https://pkg.pr.new/@tanstack/react-start-client@7260

@tanstack/react-start-rsc

npm i https://pkg.pr.new/@tanstack/react-start-rsc@7260

@tanstack/react-start-server

npm i https://pkg.pr.new/@tanstack/react-start-server@7260

@tanstack/router-cli

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

@tanstack/router-core

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

@tanstack/router-devtools

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

@tanstack/router-devtools-core

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

@tanstack/router-generator

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

@tanstack/router-plugin

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

@tanstack/router-ssr-query-core

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

@tanstack/router-utils

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

@tanstack/router-vite-plugin

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

@tanstack/solid-router

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

@tanstack/solid-router-devtools

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

@tanstack/solid-router-ssr-query

npm i https://pkg.pr.new/@tanstack/solid-router-ssr-query@7260

@tanstack/solid-start

npm i https://pkg.pr.new/@tanstack/solid-start@7260

@tanstack/solid-start-client

npm i https://pkg.pr.new/@tanstack/solid-start-client@7260

@tanstack/solid-start-server

npm i https://pkg.pr.new/@tanstack/solid-start-server@7260

@tanstack/start-client-core

npm i https://pkg.pr.new/@tanstack/start-client-core@7260

@tanstack/start-fn-stubs

npm i https://pkg.pr.new/@tanstack/start-fn-stubs@7260

@tanstack/start-plugin-core

npm i https://pkg.pr.new/@tanstack/start-plugin-core@7260

@tanstack/start-server-core

npm i https://pkg.pr.new/@tanstack/start-server-core@7260

@tanstack/start-static-server-functions

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

@tanstack/start-storage-context

npm i https://pkg.pr.new/@tanstack/start-storage-context@7260

@tanstack/valibot-adapter

npm i https://pkg.pr.new/@tanstack/valibot-adapter@7260

@tanstack/virtual-file-routes

npm i https://pkg.pr.new/@tanstack/virtual-file-routes@7260

@tanstack/vue-router

npm i https://pkg.pr.new/@tanstack/vue-router@7260

@tanstack/vue-router-devtools

npm i https://pkg.pr.new/@tanstack/vue-router-devtools@7260

@tanstack/vue-router-ssr-query

npm i https://pkg.pr.new/@tanstack/vue-router-ssr-query@7260

@tanstack/vue-start

npm i https://pkg.pr.new/@tanstack/vue-start@7260

@tanstack/vue-start-client

npm i https://pkg.pr.new/@tanstack/vue-start-client@7260

@tanstack/vue-start-server

npm i https://pkg.pr.new/@tanstack/vue-start-server@7260

@tanstack/zod-adapter

npm i https://pkg.pr.new/@tanstack/zod-adapter@7260

commit: bc40c09

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Apr 25, 2026

Merging this PR will not alter performance

✅ 5 untouched benchmarks
⏩ 1 skipped benchmark1


Comparing fix/issue-7092 (bc40c09) with main (d20c878)

Open in CodSpeed

Footnotes

  1. 1 benchmark was skipped, so the baseline result was used instead. If it was deleted from the codebase, click here and archive it to remove it from the performance reports.

Copy link
Copy Markdown
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: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/solid-router/tests/fileRoute.test-d.tsx`:
- Around line 152-163: Remove the Git conflict markers and the createMiddleware
variant and keep the mocked middleware from the "Stashed changes" branch: update
the test named test(...) to the "when creating a file route with middleware
options" variant, define the local Middleware type and the const middleware as
in the stashed version (so the later assertion toEqualTypeOf<readonly
[Middleware]>() matches), and delete any references to createMiddleware or the
server middleware branch; ensure there are no remaining <<<<<<<, =======, or
>>>>>>> markers so the file compiles.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e2038ed4-6e22-493c-8e1b-c9241aaa5870

📥 Commits

Reviewing files that changed from the base of the PR and between 324202b and e2ce65a.

📒 Files selected for processing (1)
  • packages/solid-router/tests/fileRoute.test-d.tsx

Comment thread packages/solid-router/tests/fileRoute.test-d.tsx Outdated
Copy link
Copy Markdown
Contributor

@nx-cloud nx-cloud Bot left a comment

Choose a reason for hiding this comment

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

Nx Cloud is proposing a fix for your failed CI:

We resolved unresolved git merge conflict markers left in packages/solid-router/tests/fileRoute.test-d.tsx that were causing a SyntaxError at parse time, failing the unit test run. Our fix selects the correct conflict side — a self-contained type-level test using a simple as const object — which directly validates the const TMiddlewares type parameter fix introduced in fileRoute.ts.

Tip

We verified this fix by re-running @tanstack/solid-router:test:eslint, @tanstack/solid-router:test:unit.

Suggested Fix changes
diff --git a/packages/solid-router/tests/fileRoute.test-d.tsx b/packages/solid-router/tests/fileRoute.test-d.tsx
index 46f74e2128..6c32156b2d 100644
--- a/packages/solid-router/tests/fileRoute.test-d.tsx
+++ b/packages/solid-router/tests/fileRoute.test-d.tsx
@@ -149,18 +149,9 @@ test('when creating a folder group', () => {
   expectTypeOf<'/protected'>(protectedRoute.id)
 })
 
-<<<<<<< Updated upstream
-test('when creating a file route with server middleware', () => {
-  const middleware = createMiddleware({ type: 'request' }).server(
-    ({ next }) => {
-      return next({ context: { supportsGzip: true } })
-    },
-  )
-=======
 test('when creating a file route with middleware options', () => {
   type Middleware = { readonly middleware: 'middleware' }
   const middleware = { middleware: 'middleware' } as const
->>>>>>> Stashed changes
 
   const route = createFileRoute('/invoices')({
     server: {
@@ -168,28 +159,29 @@ test('when creating a file route with middleware options', () => {
     },
   })
 
-  type ExtractMiddlewares<TRoute> = TRoute extends Route<
-    any,
-    any,
-    any,
-    any,
-    any,
-    any,
-    any,
-    any,
-    any,
-    any,
-    any,
-    any,
-    any,
-    any,
-    any,
-    any,
-    infer TMiddlewares,
-    any
-  >
-    ? TMiddlewares
-    : never
+  type ExtractMiddlewares<TRoute> =
+    TRoute extends Route<
+      any,
+      any,
+      any,
+      any,
+      any,
+      any,
+      any,
+      any,
+      any,
+      any,
+      any,
+      any,
+      any,
+      any,
+      any,
+      any,
+      infer TMiddlewares,
+      any
+    >
+      ? TMiddlewares
+      : never
 
   expectTypeOf<ExtractMiddlewares<typeof route>>().toEqualTypeOf<
     readonly [Middleware]

Apply fix via Nx Cloud  Reject fix via Nx Cloud


Or Apply changes locally with:

npx nx-cloud apply-locally VFRC-IpPd

Apply fix locally with your editor ↗   View interactive diff ↗



🎓 Learn more about Self-Healing CI on nx.dev

Copy link
Copy Markdown
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: 1

🧹 Nitpick comments (2)
packages/solid-router/tests/fileRoute.test-d.tsx (2)

152-160: Consider also asserting the original issue's runtime shape (context propagation).

Issue #7092 is specifically about context returned from a server middleware being inferred as undefined in a child route's server handler. This test only verifies that the middleware array type round-trips through Route — it does not exercise a middleware whose next({ context: {...} }) output should flow into a child handler's context parameter, which is the actual symptom users reported. A complementary expectTypeOf on the inferred context parameter of a child route's server handler (using createMiddleware(...).server(({ next }) => next({ context: { supportsGzip: true } }))) would more directly prevent regression of the linked issue.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/solid-router/tests/fileRoute.test-d.tsx` around lines 152 - 160, Add
a complementary type-level assertion that verifies context propagation from
middleware into a child route handler: create a middleware using
createMiddleware(...).server(({ next }) => next({ context: { supportsGzip: true
} })), attach it to createFileRoute('/invoices') via the server.middleware
array, then use expectTypeOf on the child route's server handler context
parameter to assert it is inferred as { supportsGzip: boolean } (or the exact
type you used); this will directly test that the middleware's next({ context:
... }) output flows into the child route's server handler context and prevent
regression of issue `#7092`.

162-183: Position-based Route<...> inference is brittle, but the proposed refactor isn't feasible.

ExtractMiddlewares relies on positional extraction, which is fragile: any reordering or insertion of generics in Route could silently break the type. However, the current implementation is correct—TServerMiddlewares is the 17th generic (with 16 anys before it, not 17), and the assertion works as intended.

The suggested refactor using T['types']['middleware'] isn't viable because RouteTypes doesn't expose a middleware property, despite carrying the TServerMiddlewares type parameter. While the brittleness concern is valid, a safer approach would be to document the dependency clearly or consider whether this level of type-testing complexity is necessary.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/solid-router/tests/fileRoute.test-d.tsx` around lines 162 - 183,
ExtractMiddlewares relies on positional inference from Route to pull out the
TServerMiddlewares generic and the current implementation is correct
(TMiddlewares is the 17th generic after 16 `any`s); revert any refactor that
replaced this with T['types']['middleware'] and instead add an inline
comment/documentation near the ExtractMiddlewares type and/or Route definition
explaining the positional dependency, referencing Route, ExtractMiddlewares,
RouteTypes and the TServerMiddlewares generic so future maintainers understand
why positional inference is used and why RouteTypes does not expose a middleware
property.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/solid-router/tests/fileRoute.test-d.tsx`:
- Around line 5-50: The test declares module augmentations for
FilebaseRouteOptionsInterface and RouteTypes which hides a missing production
augmentation; move these declarations out of the test and into the solid-router
source (e.g., add them to packages/solid-router/src/fileRoute.ts or a new
augmentation file in that package) so that the server?: { middleware?:
TServerMiddlewares } property on FilebaseRouteOptionsInterface and the
middleware: TServerMiddlewares field on RouteTypes are exported as real library
type augmentations and available to consumers; update exports or add a .d.ts
augmentation file within the solid-router package containing the same interface
augmentations and remove the test-local declarations.

---

Nitpick comments:
In `@packages/solid-router/tests/fileRoute.test-d.tsx`:
- Around line 152-160: Add a complementary type-level assertion that verifies
context propagation from middleware into a child route handler: create a
middleware using createMiddleware(...).server(({ next }) => next({ context: {
supportsGzip: true } })), attach it to createFileRoute('/invoices') via the
server.middleware array, then use expectTypeOf on the child route's server
handler context parameter to assert it is inferred as { supportsGzip: boolean }
(or the exact type you used); this will directly test that the middleware's
next({ context: ... }) output flows into the child route's server handler
context and prevent regression of issue `#7092`.
- Around line 162-183: ExtractMiddlewares relies on positional inference from
Route to pull out the TServerMiddlewares generic and the current implementation
is correct (TMiddlewares is the 17th generic after 16 `any`s); revert any
refactor that replaced this with T['types']['middleware'] and instead add an
inline comment/documentation near the ExtractMiddlewares type and/or Route
definition explaining the positional dependency, referencing Route,
ExtractMiddlewares, RouteTypes and the TServerMiddlewares generic so future
maintainers understand why positional inference is used and why RouteTypes does
not expose a middleware property.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 288496e4-f6ea-4eb3-a1ae-b5bef4152827

📥 Commits

Reviewing files that changed from the base of the PR and between e2ce65a and 36b126c.

📒 Files selected for processing (1)
  • packages/solid-router/tests/fileRoute.test-d.tsx

Comment on lines +5 to +50
declare module '@tanstack/router-core' {
interface FilebaseRouteOptionsInterface<
TRegister,
TParentRoute,
TId,
TPath,
TSearchValidator,
TParams,
TLoaderDeps,
TLoaderFn,
TRouterContext,
TRouteContextFn,
TBeforeLoadFn,
TRemountDepsFn,
TSSR,
TServerMiddlewares,
THandlers,
> {
server?: {
middleware?: TServerMiddlewares
}
}

interface RouteTypes<
TRegister,
TParentRoute,
TPath,
TFullPath,
TCustomId,
TId,
TSearchValidator,
TParams,
TRouterContext,
TRouteContextFn,
TBeforeLoadFn,
TLoaderDeps,
TLoaderFn,
TChildren,
TFileRouteTypes,
TSSR,
TServerMiddlewares,
THandlers,
> {
middleware: TServerMiddlewares
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check whether FilebaseRouteOptionsInterface / RouteTypes augmentations exist in production solid-router sources.
fd -t f -e ts -e tsx . packages/solid-router/src | xargs rg -nP "declare module '@tanstack/router-core'|FilebaseRouteOptionsInterface|RouteTypes\b" -C2

Repository: TanStack/router

Length of output: 5244


🏁 Script executed:

# Read the full module augmentation in fileRoute.ts
cat -n packages/solid-router/src/fileRoute.ts | sed -n '182,220p'

Repository: TanStack/router

Length of output: 1419


🏁 Script executed:

# Search for FilebaseRouteOptionsInterface augmentation in production
rg -nP "FilebaseRouteOptionsInterface" packages/solid-router/src

Repository: TanStack/router

Length of output: 41


🏁 Script executed:

# Search for FilebaseRouteOptionsInterface augmentation in router-core package
fd -type f -e ts -e tsx . packages/router-core | xargs rg -nP "FilebaseRouteOptionsInterface|declare module.*@tanstack/router-core" -C3

Repository: TanStack/router

Length of output: 14521


🏁 Script executed:

# Also check what's exported from packages/router-core/src/fileRoute.ts if it exists
cat -n packages/router-core/src/fileRoute.ts 2>/dev/null | head -100

Repository: TanStack/router

Length of output: 3102


🏁 Script executed:

# Read the full FilebaseRouteOptionsInterface definition in router-core
cat -n packages/router-core/src/route.ts | sed -n '944,1000p'

Repository: TanStack/router

Length of output: 1750


🏁 Script executed:

# Check if FilebaseRouteOptionsInterface has any augmentation in solid-router production code
rg -nP "declare module|server\?" packages/solid-router/src/fileRoute.ts packages/solid-router/src/route.tsx -C5

Repository: TanStack/router

Length of output: 1785


🏁 Script executed:

# Check what the start-client-core augmentation looks like for FilebaseRouteOptionsInterface
cat -n packages/start-client-core/src/serverRoute.ts | sed -n '15,80p'

Repository: TanStack/router

Length of output: 2161


Move module augmentations to solid-router production code.

The FilebaseRouteOptionsInterface and RouteTypes augmentations in this test file are test-only declarations. While start-client-core (the full-stack framework) includes these augmentations in production, solid-router (the routing library) does not. This means:

  • The test passes because it declares the types locally
  • End users of @tanstack/solid-router won't receive server.middleware typing support
  • The test doesn't actually validate what consumers experience

Move these augmentations to packages/solid-router/src/fileRoute.ts or a dedicated augmentation file so that users of solid-router get proper type support for server middleware.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/solid-router/tests/fileRoute.test-d.tsx` around lines 5 - 50, The
test declares module augmentations for FilebaseRouteOptionsInterface and
RouteTypes which hides a missing production augmentation; move these
declarations out of the test and into the solid-router source (e.g., add them to
packages/solid-router/src/fileRoute.ts or a new augmentation file in that
package) so that the server?: { middleware?: TServerMiddlewares } property on
FilebaseRouteOptionsInterface and the middleware: TServerMiddlewares field on
RouteTypes are exported as real library type augmentations and available to
consumers; update exports or add a .d.ts augmentation file within the
solid-router package containing the same interface augmentations and remove the
test-local declarations.

Copy link
Copy Markdown
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.

♻️ Duplicate comments (1)
packages/solid-router/tests/fileRoute.test-d.tsx (1)

5-50: ⚠️ Potential issue | 🔴 Critical

Module augmentations belong in solid-router production sources, not the test file.

The FilebaseRouteOptionsInterface and RouteTypes augmentations declared here are what enable server.middleware to be inferred and surfaced on the route type. Because they live in the test file, the test will pass but consumers of @tanstack/solid-router will not get this typing — which is precisely the bug reported in #7092 (compare with start-client-core/src/serverRoute.ts, which augments these interfaces in production). The const-generic change to TMiddlewares in fileRoute.ts only fixes inference; without the augmentations being shipped, end-user Route types still won't expose the middleware-derived context.

Please move these declare module '@tanstack/router-core' blocks into packages/solid-router/src/fileRoute.ts (or a dedicated .d.ts) and keep the test file consuming them as a real library user would. Otherwise this PR validates a fix that consumers won't actually receive.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/solid-router/tests/fileRoute.test-d.tsx` around lines 5 - 50, Move
the module augmentation that declares FilebaseRouteOptionsInterface and
RouteTypes out of the test and into the library sources so consumers get the
types: add the declare module '@tanstack/router-core' block (the augmentations
that add server?: { middleware?: TServerMiddlewares } to
FilebaseRouteOptionsInterface and middleware: TServerMiddlewares to RouteTypes)
into packages/solid-router/src/fileRoute.ts (or a new .d.ts in the package),
ensure it lives alongside the fileRoute.ts changes that introduced the
const-generic TMiddlewares and references server.middleware, and keep the test
file unchanged so it consumes the augmentation as an external user would.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@packages/solid-router/tests/fileRoute.test-d.tsx`:
- Around line 5-50: Move the module augmentation that declares
FilebaseRouteOptionsInterface and RouteTypes out of the test and into the
library sources so consumers get the types: add the declare module
'@tanstack/router-core' block (the augmentations that add server?: {
middleware?: TServerMiddlewares } to FilebaseRouteOptionsInterface and
middleware: TServerMiddlewares to RouteTypes) into
packages/solid-router/src/fileRoute.ts (or a new .d.ts in the package), ensure
it lives alongside the fileRoute.ts changes that introduced the const-generic
TMiddlewares and references server.middleware, and keep the test file unchanged
so it consumes the augmentation as an external user would.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8c18c985-7d53-4628-bc0d-f35ae8d07db2

📥 Commits

Reviewing files that changed from the base of the PR and between 36b126c and bc40c09.

📒 Files selected for processing (1)
  • packages/solid-router/tests/fileRoute.test-d.tsx

@birkskyum birkskyum merged commit b732c8a into main Apr 25, 2026
17 checks passed
@birkskyum birkskyum deleted the fix/issue-7092 branch April 25, 2026 17:23
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.

context returned from server middleware is incorrectly typed as undefined only in Solid Start

2 participants