Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Property 'userImage' does not exist on type '{ [fieldname: string]: File[]; } | File[]'. Property 'userImage' does not exist on type 'File[]' #332

Open
faruuhan opened this issue Sep 26, 2022 · 2 comments

Comments

@faruuhan
Copy link

How to fix this ? i'm using typescript

image

@flolu
Copy link

flolu commented Nov 28, 2022

import {FileArray, UploadedFile} from 'express-fileupload'

const reqFile = (req.files as FileArray).file as UploadedFile
if (!reqFile) throw 'No file to upload'

// do something

@jjarvela
Copy link

jjarvela commented Feb 15, 2024

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants