Open faruuhan opened 1 year ago
import {FileArray, UploadedFile} from 'express-fileupload'
const reqFile = (req.files as FileArray).file as UploadedFile
if (!reqFile) throw 'No file to upload'
// do something
import {FileArray, UploadedFile} from 'express-fileupload'
For me this gives:
Conversion of type '{ [fieldname: string]: File[]; } | File[]' to type 'FileArray' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.
Type 'File[]' is not comparable to type 'FileArray'.
Index signature for type 'string' is missing in type 'File[]'.ts(2352)
(property) Express.Request.files?: {
[fieldname: string]: Express.Multer.File[];
} | Express.Multer.File[]
Quickfix for this is :
const fileArray = (req.files as unknown as FileArray)
How to fix this ? i'm using typescript