Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cast redirectBack return value to TypedResponse<never> (sergiodxa#303)
## Context ATM, the current return type of `redirectBack` is `Response`, making type inference messy when doing : ```ts const fetcher = useFetcher<typeof action>(); ``` I changed the return type based on the one of `redirect` from Remix code ## Example : With my current code base were I spotted the issue **Before** <img width="771" alt="image" src="https://github.com/sergiodxa/remix-utils/assets/40292402/7963f707-9e59-4b28-b850-d9a17aee8d52"> **After** <img width="767" alt="image" src="https://github.com/sergiodxa/remix-utils/assets/40292402/f4641a6e-eb29-43d0-9492-8d1995f9c0e4"> This happen when you mix `redirectBack` with other return statements, like the following ```ts export async function action({ request }: ActionFunctionArgs) { const formData = await request.formData(); const submission = parse(formData); if (!submission.isValid) { return json(submission); } return redirectBack(request, { fallback: getRoute('/scenarios/:scenarioId', { scenarioId: fromUUID(submission.value.scenarioId), }), }); } ```
- Loading branch information