unnreaal
unnreaal
ZZod
Created by unnreaal on 11/4/2024 in #questions
unnreaal - tsconst schema = z.coerce.string()....
.optional is in ZodType, no?
37 replies
ZZod
Created by unnreaal on 11/4/2024 in #questions
unnreaal - tsconst schema = z.coerce.string()....
or at least warn users
37 replies
ZZod
Created by unnreaal on 11/4/2024 in #questions
unnreaal - tsconst schema = z.coerce.string()....
zod should throw an error
37 replies
ZZod
Created by unnreaal on 11/4/2024 in #questions
unnreaal - tsconst schema = z.coerce.string()....
bro, i edited the message (before you send the playground link)
37 replies
ZZod
Created by unnreaal on 11/4/2024 in #questions
unnreaal - tsconst schema = z.coerce.string()....
try yourself
37 replies
ZZod
Created by unnreaal on 11/4/2024 in #questions
unnreaal - tsconst schema = z.coerce.string()....
it is { name?: string | undefined; }
37 replies
ZZod
Created by unnreaal on 11/4/2024 in #questions
unnreaal - tsconst schema = z.coerce.string()....
im sure it isnt
37 replies
ZZod
Created by unnreaal on 11/4/2024 in #questions
unnreaal - tsconst schema = z.coerce.string()....
nop
37 replies
ZZod
Created by unnreaal on 11/4/2024 in #questions
unnreaal - tsconst schema = z.coerce.string()....
so zod should throw an error warning the optional can not (or is unnecessary) be used with coerce schemas
37 replies
ZZod
Created by unnreaal on 11/4/2024 in #questions
unnreaal - tsconst schema = z.coerce.string()....
but the name is always a string here
37 replies
ZZod
Created by unnreaal on 11/4/2024 in #questions
unnreaal - tsconst schema = z.coerce.string()....
const user = z.object({
name: z.coerce.string().optional(),
});

// { name: string | undefined; }
type User = z.output<user>;
const user = z.object({
name: z.coerce.string().optional(),
});

// { name: string | undefined; }
type User = z.output<user>;
37 replies
ZZod
Created by unnreaal on 11/4/2024 in #questions
unnreaal - tsconst schema = z.coerce.string()....
i mean that the type is completely wrong
37 replies
ZZod
Created by unnreaal on 11/4/2024 in #questions
unnreaal - tsconst schema = z.coerce.string()....
yes bro, i know the | undefined doesn't mean anything for z.coerce schemas
37 replies
ZZod
Created by unnreaal on 11/4/2024 in #questions
unnreaal - tsconst schema = z.coerce.string()....
no, i mean that the type (z.output) is wrong
37 replies
ZZod
Created by unnreaal on 11/4/2024 in #questions
unnreaal - tsconst schema = z.coerce.string()....
no?
37 replies
ZZod
Created by unnreaal on 11/4/2024 in #questions
unnreaal - tsconst schema = z.coerce.string()....
its a type error
37 replies
ZZod
Created by unnreaal on 11/4/2024 in #questions
unnreaal - tsconst schema = z.coerce.string()....
still the same with z.output
37 replies
ZZod
Created by Whimsy on 9/2/2024 in #questions
Whimsy - .optional() makes the type optional? l...
you don't need to use .optional when using .default @Whimsy
9 replies