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
The following typescript error occurs when trying to use an array of objects in the input of a file router
Types of property '_input' are incompatible.
Type '{ media: { id: string; }[]; }' is not assignable to type 'Json'.
Type '{ media: { id: string; }[]; }' is not assignable to type 'JsonObject'.
Property 'media' is incompatible with index signature.
Type '{ id: string; }[]' is not assignable to type 'JsonValue | JsonObject | JsonArray'.
Type '{ id: string; }[]' is not assignable to type 'JsonArray'.
Type '{ id: string; }' is not assignable to type 'JsonValue'.
The documentation only highlights that the input must be JSON serializable, which it is, so this feels like the internal json type isn't quite right. If it's intentional, it'd be helpful to mention it in the docs.
Check src/server/uploadthing.ts (line 40) in the reproduction link. When the sandbox loads, you can see the type error.
And just to have it here also, this input schema gives the error : const imageSchema = z.object({ media: z.array(z.object({ id: z.string() })) });
Additional information
It feels like the fix might just be to change these types in @uploadthing/shared, but in any case I wanted to file this to make sure I didn't miss anything 👀
typeJsonValue=string|number|boolean|null|undefined;typeJsonArray=JsonValue[];// --> use Json[] instead?typeJsonObject={[key: string]: JsonValue|JsonObject|JsonArray;// --> maybe here too};typeJson=JsonValue|JsonObject|JsonArray;
👨👧👦 Contributing
🙋♂️ Yes, I'd be down to file a PR fixing this bug!
Code of Conduct
I agree to follow this project's Code of Conduct
The text was updated successfully, but these errors were encountered:
Provide environment information
Describe the bug
The following typescript error occurs when trying to use an array of objects in the input of a file router
The documentation only highlights that the input must be JSON serializable, which it is, so this feels like the internal json type isn't quite right. If it's intentional, it'd be helpful to mention it in the docs.
Link to reproduction
https://stackblitz.com/edit/github-uvnavyz9?file=src%2Fserver%2Fuploadthing.ts&view=editor
To reproduce
Check
src/server/uploadthing.ts
(line 40) in the reproduction link. When the sandbox loads, you can see the type error.And just to have it here also, this input schema gives the error :
const imageSchema = z.object({ media: z.array(z.object({ id: z.string() })) });
Additional information
It feels like the fix might just be to change these types in
@uploadthing/shared
, but in any case I wanted to file this to make sure I didn't miss anything 👀👨👧👦 Contributing
Code of Conduct
The text was updated successfully, but these errors were encountered: