Type Issues when using `optional` in a zod schema #2345
Send to my agentLeCarbonator(GitHub profile, opens in a new tab) closed this
LeCarbonator(GitHub profile, opens in a new tab) added labelsquestion
LeCarbonator(GitHub profile, opens in a new tab) added labelsv1
LeCarbonator(GitHub profile, opens in a new tab) added labelsscope: core
LeCarbonator(GitHub profile, opens in a new tab) added labelsarea: types
Sign in to join this conversation.
Two things:
UpdateProfileInput. However, you usedz.inferwhich is the output type. The input type isz.input.satisfiesdoesn't assign, it only confirms that it could satisfy. For this case, an assertion is needed so that optional properties remain optional. There's multiple ways, but the one below is the easiest.v2#
Important
You are on v1. This is only for future readers.
This'll be made easier in v2. This compiles without needing to assign or change things: