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

validateForm has multiple types #220

Closed
jessielaf opened this issue Jul 4, 2023 · 1 comment
Closed

validateForm has multiple types #220

jessielaf opened this issue Jul 4, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@jessielaf
Copy link

Description

I am getting a type error because validateForm has two types:


/**
 * Validate current form data.
 */
export declare function validateForm<T extends AnyZodObject>(): Promise<SuperValidated<ZodValidation<T>>>;
/**
 * Validate a specific field in the form.
 */
export declare function validateForm<T extends AnyZodObject>(path: FormPathLeaves<z.infer<T>>, opts?: ValidateOptions<FormPathType<z.infer<T>, FormPathLeaves<z.infer<T>>>, T>): Promise<string[] | undefined>;
/**

I have a component which expects a superForm to be passed as a param, but I am getting an error:

Type 'SuperForm<ZodObject<{ email: ZodString; locked: ZodOptional<ZodBoolean>; authorities: ZodArray<ZodOptional<ZodNullable<ZodEnum<["ADMIN", "USER", "SHIPMENT", "TRANSPORT", "COMPANY", "TRIGGER", "ACCESS_CODE"]>>>, "many">; }, "strip", ZodTypeAny, { ...; }, { ...; }>, any>' is not assignable to type 'SuperForm<any>'.
  Types of property 'validate' are incompatible.
    Type 'typeof validateForm<UnwrapEffects<T>>' is not assignable to type 'typeof validateForm<UnwrapEffects<T>>'. Two different types with this name exist, but they are unrelated.
      Types of parameters 'path' and 'path' are incompatible.
        Type 'string' is not assignable to type 'FormPathLeaves<{ email: string; authorities: ("ADMIN" | "USER" | "SHIPMENT" | "TRANSPORT" | "COMPANY" | "TRIGGER" | "ACCESS_CODE" | null | undefined)[]; locked?: boolean | undefined; }>'.ts(2322)
@jessielaf jessielaf added the bug Something isn't working label Jul 4, 2023
@jessielaf
Copy link
Author

Nvm it had to do with the new generics in the form components

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant