Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cast redirectBack return value to TypedResponse<never> #303

Merged
merged 1 commit into from
Feb 23, 2024

Conversation

balzdur
Copy link
Contributor

@balzdur balzdur commented Feb 6, 2024

Context

ATM, the current return type of redirectBack is Response, making type inference messy when doing :

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
image

After
image

This happen when you mix redirectBack with other return statements, like the following

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),
      }),
    });
}

@sergiodxa sergiodxa added the enhancement New feature or request label Feb 23, 2024
@sergiodxa sergiodxa changed the title refactor(redirect-back): use same return as redirect Cast redirectBack return value to TypedResponse<never> Feb 23, 2024
@sergiodxa sergiodxa merged commit b9ac836 into sergiodxa:main Feb 23, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants