Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

404
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda