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

595
Views
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 answers
Answer question

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 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!