You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When using the generated code in a server environment (which might obviously become common due to React server components), the following error is thrown: ReferenceError: File is not defined
Expected behavior
I believe the ideal solution would be to generate isomorphic code that looks like the following:
schema: z.custom<File|Buffer>((data)=>{returntypeofwindow==='undefined' ? datainstanceofBuffer : datainstanceofFile},'Input is not an instance of a Buffer or File'),
Depending on the use case, the user might obviously have to assert to either File or Buffer but I think that's preferable to the code simply breaking. 😅
As you can maybe tell by looking at the rest of the app, I have already tested this approach there.
The text was updated successfully, but these errors were encountered:
Describe the bug
When using the generated code in a server environment (which might obviously become common due to React server components), the following error is thrown:
ReferenceError: File is not defined
Minimal reproduction
See this branch: https://github.com/s-h-a-d-o-w/openapi-zod-client-experiment/tree/file-problem-repro
The error is emitted when running the dev server.
Expected behavior
I believe the ideal solution would be to generate isomorphic code that looks like the following:
Depending on the use case, the user might obviously have to assert to either
File
orBuffer
but I think that's preferable to the code simply breaking. 😅As you can maybe tell by looking at the rest of the app, I have already tested this approach there.
The text was updated successfully, but these errors were encountered: