-
With the following loader function: type LoaderData = {
content: string;
}
export async function loader({ params, request }: LoaderFunctionArgs) {
if (hasNoAccess) {
return redirect('/login');
}
return json<LoaderData>({ content: 'Hello World' });
} I would expect the return type of the loader to be: Promise<TypedResponse<LoaderData>> But in this case it is: Promise<Response> This means that the Anyone got any suggestions? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 10 replies
-
Hey, First thing first, you shouldn't need to define/use
What you can do instead, is change export async function loader({ params, request }: LoaderFunctionArgs) {
if (hasNoAccess) {
throw redirect('/login');
}
return json({ content: 'Hello World' });
} |
Beta Was this translation helpful? Give feedback.
What remix version are you using?
I'm using 1.16.0 and seeing this behavior:
✅ inference of with json() & redirect()
✅ inference of with 2 non-empty json()
🐛 inference is broken if you return an empty object
Also, could you possibly be mixing imports and importing
json
oruseLoaderData
fromreact-router
instead of@remix-run/xxx
?