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

106
Views
¿Cómo puedo hacer que el 'tipo de sugerencia' mecanografiado sea más limitado en el código?

consejo mecanografiado: el paso es any tipo. ¡Esto es muy malo!

¿Cómo optimizo?

 export function foo (isActive:boolean) { let step if (isActive) { step = [ '1ICK750', '2IYE230', '3CI0320', '3CI0720', '4PGC938' ] as const } else { step = [ 'are', 'by', 'sea', 'seashells', 'she', 'shore', 'the', 'zoo' ] as const } // ...more // typescript tip: step is any type.This is too bad! return step }
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

puedes hacer el paso así

 let step: string[] = []

ahora su tipo de devolución también será una cadena de matriz.

about 4 years ago · Juan Pablo Isaza Report

0

Defínalo usando el operador condicional en su lugar.

 const step = isActive ? ['1ICK750', '2IYE230', '3CI0320', '3CI0720', '4PGC938'] as const : ['are', 'by', 'sea', 'seashells', 'she', 'shore', 'the', 'zoo'] as const;
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!