Skip to content

Conversation

edmolima
Copy link

@edmolima edmolima commented Oct 3, 2025

  • Update useLoaderDeps return type to Accessor for consistency with Solid.js patterns
  • Add import for Accessor type from solid-js
  • Reorganize imports following project conventions (types first, then implementations)
  • Add comprehensive tests for useLoaderDeps Accessor behavior
  • Update type tests to reflect new Accessor return type

Fixes #5343

Summary by CodeRabbit

  • New Features
    • useLoaderDeps (including via route APIs) now returns Accessor-wrapped results for reactive consumption.
  • Refactor
    • Public typings and exports adjusted to reflect Accessor-based return types.
  • Tests
    • Added/updated tests validating Accessor behavior for useLoaderDeps in direct route and route-API usage.

- Update useLoaderDeps return type to Accessor for consistency with Solid.js patterns
- Add import for Accessor type from solid-js
- Reorganize imports following project conventions (types first, then implementations)
- Add comprehensive tests for useLoaderDeps Accessor behavior
- Update type tests to reflect new Accessor return type
Copy link
Contributor

coderabbitai bot commented Oct 3, 2025

Walkthrough

Return types for useLoaderDeps in the Solid Router were changed to be wrapped in Solid's Accessor; the implementation and types were updated accordingly, and tests were added/updated to expect and verify the Accessor-returning API.

Changes

Cohort / File(s) Summary of changes
Solid Router API: Accessor-wrapped return types
packages/solid-router/src/useLoaderDeps.tsx
Added import type { Accessor } from 'solid-js'. Changed UseLoaderDepsRoute and useLoaderDeps return types to Accessor<UseLoaderDepsResult<...>>. Updated final cast to Accessor<UseLoaderDepsResult<...>>.
Solid Router tests: behavior and type expectations
packages/solid-router/tests/route.test.tsx, packages/solid-router/tests/routeApi.test-d.tsx
Added/updated tests to assert useLoaderDeps() returns an Accessor whose invocation yields the loaderDeps result. Updated type test to expect Accessor<{ dep: number }>. Minor import formatting change.

Sequence Diagram(s)

sequenceDiagram
  participant Component as Consumer Component
  participant RouteAPI as Route / getRouteApi
  participant useLoaderDeps as useLoaderDeps (API)
  rect rgb(230, 250, 230)
    Note over useLoaderDeps: Public API now returns an Accessor (function)
  end
  Component->>RouteAPI: call Route.useLoaderDeps() or api.useLoaderDeps()
  RouteAPI->>useLoaderDeps: return Accessor<LoaderDepsResult>
  alt when consumer needs data
    Component->>useLoaderDeps: invoke Accessor() -> ()
    useLoaderDeps-->>Component: LoaderDepsResult (object)
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • schiller-manuel

Poem

A rabbit taps the keys with care and cheer,
Wrapping deps in Accessors, hoppity near.
Tests peek and prod, then nod and clap,
Types align, no more mismatch trap.
A tiny thump — the patch is clear. 🐇✨

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 precisely reflects the main change by stating that useLoaderDeps will now return an Accessor to improve reactivity in solid-router, matching the code modifications and the linked issue objective. It is concise, clear, and focused on the key change without extraneous details.
Linked Issues Check ✅ Passed The changes update both the type definitions and implementations of Route.useLoaderDeps and useLoaderDeps to return an Accessor, and the added tests verify that behavior, fully addressing issue #5343’s requirement to align TypeScript typings with runtime behavior.
Out of Scope Changes Check ✅ Passed All modifications are focused on updating the useLoaderDeps API, its TypeScript signatures, and related tests, with no unrelated code or functionality introduced beyond the objectives.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 45f2ea0 and 300a845.

📒 Files selected for processing (2)
  • packages/solid-router/src/useLoaderDeps.tsx (2 hunks)
  • packages/solid-router/tests/routeApi.test-d.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/solid-router/src/useLoaderDeps.tsx
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

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

Files:

  • packages/solid-router/tests/routeApi.test-d.tsx
packages/{react-router,solid-router}/**

📄 CodeRabbit inference engine (AGENTS.md)

Implement React and Solid bindings/components only in packages/react-router/ and packages/solid-router/

Files:

  • packages/solid-router/tests/routeApi.test-d.tsx
🔇 Additional comments (1)
packages/solid-router/tests/routeApi.test-d.tsx (1)

91-95: LGTM! Type test correctly updated for Accessor return type.

The change aligns useLoaderDeps with the other hooks (useParams, useRouteContext, useSearch, useLoaderData) which all return Accessor-wrapped types, ensuring consistency with Solid.js reactive patterns. This fixes the type mismatch between the declared types and the actual runtime behavior.


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.

@edmolima
Copy link
Author

edmolima commented Oct 3, 2025

@coderabbitai review

Copy link
Contributor

coderabbitai bot commented Oct 3, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@edmolima edmolima marked this pull request as ready for review October 3, 2025 07:57
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/solid-router/tests/route.test.tsx (2)

207-227: LGTM: Comprehensive test for Accessor behavior.

The test correctly verifies that useLoaderDeps() returns an Accessor (function) and that calling it yields the expected loaderDeps result. The test structure is clear and covers the direct route usage path.

Minor refinement: the loaderDeps callback has an unused { search } parameter. Consider removing it for clarity:

-      loaderDeps: ({ search }) => ({ testDep: 'value' }),
+      loaderDeps: () => ({ testDep: 'value' }),

229-249: LGTM: Route API test covers Accessor usage.

This test validates the same Accessor behavior via getRouteApi('/'), ensuring both access paths (direct route and route API) behave consistently.

Minor refinement: the loaderDeps callback has an unused { search } parameter. Consider removing it for clarity:

-      loaderDeps: ({ search }) => ({ testDep: 'api-value' }),
+      loaderDeps: () => ({ testDep: 'api-value' }),
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ac35dd2 and 45f2ea0.

📒 Files selected for processing (3)
  • packages/solid-router/src/useLoaderDeps.tsx (2 hunks)
  • packages/solid-router/tests/route.test.tsx (2 hunks)
  • packages/solid-router/tests/routeApi.test-d.tsx (2 hunks)
🔇 Additional comments (6)
packages/solid-router/tests/route.test.tsx (1)

2-2: LGTM: Import reorganization.

The vitest import has been reformatted with no change to the imported symbols.

packages/solid-router/tests/routeApi.test-d.tsx (2)

1-2: LGTM: Type imports added for Accessor support.

The added imports (MakeRouteMatch, UseNavigateResult, Accessor) are necessary for the updated type tests and align with the new Accessor-wrapped return types.


91-95: LGTM: Type test updated for Accessor return type.

The type expectation correctly verifies that useLoaderDeps() returns Accessor<{ dep: number }> instead of a plain object, consistent with the implementation change.

packages/solid-router/src/useLoaderDeps.tsx (3)

8-9: LGTM: Accessor type imported for reactivity support.

The Accessor type import from solid-js is necessary for the new return type and aligns with Solid.js reactivity patterns. The existing useMatch import is retained.


26-31: LGTM: UseLoaderDepsRoute return type wrapped in Accessor.

The return type correctly wraps the result in Accessor<...>, making the API reactive and consistent with Solid.js patterns.


33-47: LGTM: useLoaderDeps implementation updated to return Accessor.

The implementation correctly:

  • Updates the return type to Accessor<UseLoaderDepsResult<...>>
  • Delegates to useMatch, which already returns an Accessor
  • Applies the select transformation to extract loaderDeps from the match state
  • Uses a type assertion on Line 46 to align the return type (safe because useMatch returns Accessor and the select function transforms the wrapped value)

@edmolima
Copy link
Author

edmolima commented Oct 3, 2025

@coderabbitai generate docstrings

Copy link
Contributor

coderabbitai bot commented Oct 3, 2025

✅ Actions performed

Docstrings generation started.

coderabbitai bot added a commit that referenced this pull request Oct 3, 2025
Docstrings generation was requested by @edmolima.

* #5348 (comment)

The following files were modified:

* `packages/solid-router/src/useLoaderDeps.tsx`
Copy link
Contributor

coderabbitai bot commented Oct 3, 2025

Note

Generated docstrings for this pull request at #5349

Copy link
Contributor

@brenelz brenelz left a comment

Choose a reason for hiding this comment

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

Nice this looks good to me

Copy link

nx-cloud bot commented Oct 4, 2025

🤖 Nx Cloud AI Fix Eligible

An automatically generated fix could have helped fix failing tasks for this run, but Self-healing CI is disabled for this workspace. Visit workspace settings to enable it and get automatic fixes in future runs.

To disable these notifications, a workspace admin can disable them in workspace settings.


View your CI Pipeline Execution ↗ for commit 45f2ea0

Command Status Duration Result
nx affected --targets=test:eslint,test:unit,tes... ❌ Failed 5m 37s View ↗
nx run-many --target=build --exclude=examples/*... ✅ Succeeded 25s View ↗

☁️ Nx Cloud last updated this comment at 2025-10-04 18:45:50 UTC

Copy link

pkg-pr-new bot commented Oct 4, 2025

More templates

@tanstack/arktype-adapter

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

@tanstack/directive-functions-plugin

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

@tanstack/eslint-plugin-router

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

@tanstack/history

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

@tanstack/nitro-v2-vite-plugin

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

@tanstack/react-router

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

@tanstack/react-router-devtools

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

@tanstack/react-router-ssr-query

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

@tanstack/react-start

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

@tanstack/react-start-client

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

@tanstack/react-start-server

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

@tanstack/router-cli

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

@tanstack/router-core

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

@tanstack/router-devtools

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

@tanstack/router-devtools-core

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

@tanstack/router-generator

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

@tanstack/router-plugin

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

@tanstack/router-ssr-query-core

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

@tanstack/router-utils

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

@tanstack/router-vite-plugin

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

@tanstack/server-functions-plugin

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

@tanstack/solid-router

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

@tanstack/solid-router-devtools

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

@tanstack/solid-start

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

@tanstack/solid-start-client

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

@tanstack/solid-start-server

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

@tanstack/start-client-core

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

@tanstack/start-plugin-core

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

@tanstack/start-server-core

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

@tanstack/start-static-server-functions

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

@tanstack/start-storage-context

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

@tanstack/valibot-adapter

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

@tanstack/virtual-file-routes

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

@tanstack/zod-adapter

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

commit: 45f2ea0

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.

SolidJS Router's Route.useLoaderDeps's typing should be wrapped in Accessor<T>
2 participants