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

102
Views
Dada una función sobrecargada y tipos de parámetros, ¿busca el tipo de retorno en Typescript?

Según esta respuesta ( https://stackoverflow.com/a/52761156/599184 ), ReturnType<> no funciona con funciones sobrecargadas en general. Sin embargo, ¿sería posible seleccionar una versión particular de la función sobrecargada y obtener su tipo de devolución?

La única forma que se me ocurre es tener un código que invoque la función sobrecargada.

 function fn(arg: string): string; function fn(arg: number): number; function fn(arg: string | number): string | number { return arg; } const temp1 = () => fn('string'); type Type1 = ReturnType<typeof temp1>; // string const temp2 = () => fn(123); type Type2 = ReturnType<typeof temp2>; // number

Parque infantil TS

¿Hay alguna forma más limpia en la que no tenga que pasar los argumentos (solo el tipo de argumento)?

about 4 years ago · Juan Pablo Isaza
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!