Skip to content

Commit

Permalink
fix(react-router): Correct types for data() usage in callback (#4853)
Browse files Browse the repository at this point in the history
  • Loading branch information
LekoArts authored Jan 8, 2025
1 parent 7d1bd40 commit 620b8d2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/large-phones-peel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@clerk/react-router': patch
---

Previously, when the `data()` utility was used inside the callback of `rootAuthLoader()` type errors were thrown. These issues should be fixed now.
10 changes: 8 additions & 2 deletions packages/react-router/src/ssr/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type {
SignUpFallbackRedirectUrl,
SignUpForceRedirectUrl,
} from '@clerk/types';
import type { LoaderFunction } from 'react-router';
import type { LoaderFunction, UNSAFE_DataWithResponseInit } from 'react-router';
import type { CreateServerLoaderArgs } from 'react-router/route-module';

type Func = (...args: any[]) => unknown;
Expand Down Expand Up @@ -97,7 +97,13 @@ type ObjectLike = Record<string, unknown> | null;
*
* In the case of `null`, we will return an object containing only the authentication state.
*/
export type RootAuthLoaderCallbackReturn = Promise<Response> | Response | Promise<ObjectLike> | ObjectLike;
type RootAuthLoaderCallbackReturn =
| Promise<Response>
| Response
| Promise<ObjectLike>
| ObjectLike
| UNSAFE_DataWithResponseInit<unknown>
| Promise<UNSAFE_DataWithResponseInit<unknown>>;

// TODO: Figure out how to use the Route.LoaderArgs from userland code
export type LoaderFunctionArgs = CreateServerLoaderArgs<RouteInfo>;
Expand Down

0 comments on commit 620b8d2

Please sign in to comment.