Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

602
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda