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

597
Vistas
TS4060: Return type of exported function has or is using private name <name>

I have this example code:

function myFunction(base: string): typeof getter {
 function getter(contactInfo: ContactInfo): Address[] {
   ...
   return address;
 }
 
 return getter;
}

export default myFunction;

But when I try to do a build with declaration files, I have the following error:

error TS4060: Return type of exported function has or is using private name 'getter'. 23 function myFunction(base: string): typeof getter {

I can fix it adding the type of getter instead of typeof:

function myFunction(base: string): (contactInfo: ContactInfo) => Address[] {
 function getter(contactInfo: ContactInfo): Address[] {
   ...
   return address;
 }

 return getter;
}

export default myFunction;

But there are some files that are more complicated than this. There is a way to avoid this error using typeof getter instead of passing all the types?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I believe the best way to handle this is to remove the function type. TypeScript is smart enough to infer the return type of the function without an explicit notation.

function myFunction(base: string) {
 function getter(contactInfo: ContactInfo): Address[] {   
   return address;
 }
 
 return getter;
}

export default myFunction;  
// inferred type is: 
// function myFunction(base: string): (contactInfo: ContactInfo) => Address[]
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