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

executeFormAction type issue #217

Open
jericopulvera opened this issue Sep 27, 2024 · 6 comments
Open

executeFormAction type issue #217

jericopulvera opened this issue Sep 27, 2024 · 6 comments

Comments

@jericopulvera
Copy link

image

Type '((...opts: any) => Promise) | ((...opts: any) => Promise) | ((...opts: any) => Promise) | ((...opts: any) => Promise) | ((...opts: any) => Promise<...>)' is not assignable
to type 'string | ((formData: FormData) => void | Promise) | undefined'.
Type '(...opts: any) => Promise' is not assignable to type 'string | ((formData: FormData) => void | Promise) | undefined'.
Type '(...opts: any) => Promise' is not assignable to type '(formData: FormData) => void | Promise'.
Type 'Promise' is not assignable to type 'void | Promise'.
Type 'Promise' is not assignable to type 'Promise'.
Type 'null' is not assignable to type 'void'. [2322]

@IdoPesok
Copy link
Owner

Hi, can you share more code to help repro?

@nahtnam
Copy link

nahtnam commented Sep 29, 2024

I have this issue as well after an update from 0.2.2 to 0.2.3

<form action={executeFormAction} className="flex w-full items-end gap-4">
const { isPending, executeFormAction, isError, error } =
    useServerAction(createOrganization);
export const createOrganization = authenticatedProcedure
  .createServerAction()
  .input(
    z.object({
      name: z.string().min(1).max(255),
    }),
    {
      type: "formData",
    },
  )
  .handler(async ({ input, ctx }) => {
    const { name } = input;

    await x.db.organization.create({
      data: {
        name,
        userId: ctx.user.id,
      },
    });

    return redirect("/onboarding");
  });

@nahtnam
Copy link

nahtnam commented Sep 29, 2024

After further debugging, the issue actually happens for me when updating @types/react from 18.3.5 to 18.3.10

@seawatts
Copy link

Did you find a solve for this besides not updating the types?

@NovaisVictor
Copy link

NovaisVictor commented Oct 31, 2024 via email

@AarRidho
Copy link

It seems that since @types/[email protected], <form> action function returns void | Promise<void>.

This line should probably be Promise<void>, since <form> action and executeFormAction should not expect a null as a return value

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants