ciscoheat / sveltekit-superforms

Making SvelteKit forms a pleasure to use!
https://superforms.rocks
MIT License
2.11k stars 62 forks source link

Types have separate declarations of a private property '_cached'. #443

Closed ryanylee closed 2 months ago

ryanylee commented 2 months ago

Description Given this setup:

// schema.ts
import { z } from 'zod';

export const emailSchema = z.object({
  email: z
    .string()
    .email()
    .transform((value) => value.toLowerCase()),
  resend: z.boolean().optional(),
});
import { superValidate } from 'sveltekit-superforms';
import { zod } from 'sveltekit-superforms/adapters';
import { emailSchema } from './schema';

export const load = (async ({ locals }) => {
  return {
    emailForm: await superValidate(zod(emailSchema)),
  }
}

I get the following error:

Argument of type 'ZodObject<{ email: ZodEffects<ZodString, string, string>; resend: ZodOptional<ZodBoolean>; }, "strip", ZodTypeAny, { email: string; resend?: boolean | undefined; }, { ...; }>' is not assignable to parameter of type 'ZodValidation<ZodObjectTypes>'.
  Type 'ZodObject<{ email: ZodEffects<ZodString, string, string>; resend: ZodOptional<ZodBoolean>; }, "strip", ZodTypeAny, { email: string; resend?: boolean | undefined; }, { ...; }>' is not assignable to type 'AnyZodObject'.
    Types have separate declarations of a private property '_cached'.

This started happening when I updated to v2.15.1 from v2.8.0

I'm using sveltekit-superforms: 2.15.1 zod: 3.23.8

ZeroPie commented 2 months ago

@ryanylee @ciscoheat i still get this on "sveltekit-superforms": "2.15.1", CleanShot 2024-06-14 at 14 35 40

ZeroPie commented 2 months ago

nvm pnpm update zod --interactive --latest to latest fixed it