Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

400
Views
Typescript: Property 'name' does not exist on type 'FormDataEntryValue'

I have:

const file = formData.get('documents[]')

What type is file?

const file: FormDataEntryValue | null

I need to access to file?.name.

and i got:

Property 'name' does not exist on type 'FormDataEntryValue'.

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

FormDataEntryValue is defined as an union of File and string: type FormDataEntryValue = File | string;

Thus you need to check first that the variable is indeed a File:

if (file instanceof File) {
  console.log(file.name);
}
about 4 years ago · Juan Pablo Isaza Report

0

Property 'name' does not exist on type 'FormDataEntryValue'.

As error says, looks like key passed in the FormData.get() or the name property in file variable doesn't exist.

The get() method of the FormData interface always returns the first value associated with a given key from within a FormData object.

Hence, As per your code. Looks like documents is an array of object. Hence, you can access the name by file[0]?.name instead of file?.name

formData.append('documents', '[{name: "alpha"}]');

const file = formData.get('documents')

const fileName = file[0]?.name // returns alpha
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!