cstrnt / next-multiparty

Easy & Simple File Uploads for Next.js
MIT License
19 stars 3 forks source link

Got an TS error with the `withFileUpload` method #3

Open MatteoGauthier opened 1 year ago

MatteoGauthier commented 1 year ago

Hey I use your lib on my projects but I always have an error here.

Capture d’écran 2022-10-28 à 13 38 59

Can you help me ?

cstrnt commented 1 year ago

Oh hey @MatteoGauthier, for some reason I didn't get the Notification. You probably figured out the error already, but it's because with withFileUpload function updates the type of NextApiRequest so req.file is typed. You will need to change the types in your handler. Change your handler to



function handler(req: FormNextApiRequest, res: NextApiResponse) {
    // ... your code
}