June 2025posted on 06.07.2025Inferring the types from a Remix loader The loader function in Remix can be inferred automatically using: type LoaderData = Awaited<ReturnType<typeof loader>>; Awaited: Extracts the value returned from a Promise. ReturnType: Constructs a type consisting of the return type of a function. Putting it together: import { json } from "@remix-run/node"; type LoaderData = Awaited<ReturnType<typeof loader>>; // ^? LoaderData: Response export const loader = async () => { return json({ ok: true }); }; No reactions yet
Inferring the types from a Remix loader
The
loaderfunction in Remix can be inferred automatically using:Awaited: Extracts the value returned from aPromise.ReturnType: Constructs a type consisting of the return type of a function.Putting it together: