From 620b8d2785d1dcd7e16a695b894bb9e6f554c5c8 Mon Sep 17 00:00:00 2001 From: Lennart Date: Wed, 8 Jan 2025 15:55:37 +0100 Subject: [PATCH] fix(react-router): Correct types for data() usage in callback (#4853) --- .changeset/large-phones-peel.md | 5 +++++ packages/react-router/src/ssr/types.ts | 10 ++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 .changeset/large-phones-peel.md diff --git a/.changeset/large-phones-peel.md b/.changeset/large-phones-peel.md new file mode 100644 index 0000000000..8ba55d0e6e --- /dev/null +++ b/.changeset/large-phones-peel.md @@ -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. diff --git a/packages/react-router/src/ssr/types.ts b/packages/react-router/src/ssr/types.ts index 10b8a9f855..072eb783fd 100644 --- a/packages/react-router/src/ssr/types.ts +++ b/packages/react-router/src/ssr/types.ts @@ -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; @@ -97,7 +97,13 @@ type ObjectLike = Record | null; * * In the case of `null`, we will return an object containing only the authentication state. */ -export type RootAuthLoaderCallbackReturn = Promise | Response | Promise | ObjectLike; +type RootAuthLoaderCallbackReturn = + | Promise + | Response + | Promise + | ObjectLike + | UNSAFE_DataWithResponseInit + | Promise>; // TODO: Figure out how to use the Route.LoaderArgs from userland code export type LoaderFunctionArgs = CreateServerLoaderArgs;