Open
Description
I'm using React Router as a...
library
Reproduction
- throw an error in a Route loader
- The generated types asume the loaderData is always defined
- In my case when an error is thrown the data returned in the meta function is undefined
export const meta = ({ data: { id} }: Route.MetaArgs) => {
return [
{
title: id
},
];
};
export async function loader({ params: { id } }: Route.LoaderArgs) {
if (!id ) {
throw new Response("Not Found", { status: 404 });
}
return { id };
}
System Info
System:
OS: Windows 10 10.0.19045
CPU: (12) x64 Intel(R) Core(TM) i7-10850H CPU @ 2.70GHz
Memory: 9.18 GB / 31.78 GB
Binaries:
Node: 22.13.1 - C:\Program Files\nodejs\node.EXE
npm: 10.9.2 - C:\Program Files\nodejs\npm.CMD
Browsers:
Edge: Chromium (128.0.2739.113)
Internet Explorer: 11.0.19041.4355
Used Package Manager
npm
Expected Behavior
MetaArgs should take into account that the loader can throw an Error and the data from the loader can be undefined.
Actual Behavior
The types for data in the meta function is always defined (which is not true).