Skip to content

fix(react-router): fix JSDoc types for context #13170

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/lovely-cups-sniff.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"react-router": patch
---

Fix jsdoc types for `context`
11 changes: 6 additions & 5 deletions packages/react-router/lib/types/route-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,11 @@ type ClientDataFunctionArgs<T extends RouteInfo> = {
params: T["params"];
/**
* When `future.unstable_middleware` is not enabled, this is undefined.
*
* When `future.unstable_middleware` is enabled, this is an instance of
* `{@link unstable_RouterContextProvider}` and can be used to access context values
* `unstable_RouterContextProvider` and can be used to access context values
* from your route middlewares. You may pass in initial context values in your
* `{@link unstable_getContext}` function passed tp `{@link HydratedRouter}`
* `<HydratedRouter unstable_getContext>` prop
*/
context: unstable_RouterContextProvider;
};
Expand All @@ -171,15 +172,15 @@ type ServerDataFunctionArgs<T extends RouteInfo> = {
params: T["params"];
/**
* Without `future.unstable_middleware` enabled, this is the context passed in
* to your server adapter's `{@link getLoadContext}` function. It's a way to bridge the
* to your server adapter's `getLoadContext` function. It's a way to bridge the
* gap between the adapter's request/response API with your React Router app.
* It is only applicable if you are using a custom server adapter.
*
* With `future.unstable_middleware` enabled, this is an instance of
* `{@link unstable_RouterContextProvider}` and can be used for type-safe access to
* `unstable_RouterContextProvider` and can be used for type-safe access to
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This wasn't working right so removing until we can figure out the right approach after the new API docs land

Screenshot 2025-03-06 at 8 37 23 AM

* context value set in your route middlewares. If you are using a custom
* server adapter, you may provide an initial set of context values from your
* `{@link getLoadContext}` function.
* `getLoadContext` function.
*/
context: MiddlewareEnabled extends true
? unstable_RouterContextProvider
Expand Down