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

146
Views
Manera genérica de verificar si un valor de un objeto no está definido para que el compilador lo entienda

Dado un tipo T :

 type T = { akey: string | number | undefined }

Si reviso específicamente para ello

 const fun = (p: T) => { if(!p.akey) return p.akey.toString() }

akey entiende que una clave no puede estar indefinida.

Si lo hago de forma genérica sin embargo:

 const fun2 = (p: T) => { if(Object.values(p).includes(undefined)) return p.akey.toString() }

No lo hace: Object is possibly 'undefined' .

¿Cómo puedo hacer que mecanografiado entienda para no tener que hacer:

p.akey!.toString()

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!