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

247
Views
¿Cómo evitar la desestructuración de valores indefinidos en JavaScript?

Obtengo la respuesta registryReportSettings del servidor:

 this.getRegistrySettings(registry.Id).subscribe((registryReportSettings: { extended: ReportPropertiesRequest }) => { const { objectProperties, reportProperties, textProperties } = registryReportSettings?.extended; }

Si es null me sale un error:

 TypeError: Cannot destructure property 'objectProperties' of '(intermediate value)(intermediate value)(intermediate value)' as it is undefined.

¿Cómo solucionarlo usando TS?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

El error significa que intenta deconstruir un posible undefined (porque usa un encadenamiento opcional )

Tu puedes hacer

 const { objectProperties, reportProperties, textProperties } = registryReportSettings?.extended ?? {};

Así que siempre deconstruirás un objeto.

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!