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

160
Views
¿Por qué 'esto' no está definido en TypeScript?

Tengo código de ejemplo:

 export {}; class Userr{ name : string; constructor(_name:string){ this.name = _name; } } const Tom : Userr = new Userr("Tom"); const header = this.document.getElementById("header"); header.innerHTML = "Wassup " + Tom.name;

En JS parece:

 "use strict"; exports.__esModule = true; var Userr = /** @class */ (function () { function Userr(_name) { this.name = _name; } return Userr; }()); var Tom = new Userr("Tom"); var header = this.document.getElementById("header"); header.innerHTML = "Wassup " + Tom.name;

IDE (VS Code) dice que en el archivo .ts tengo un error:
error TS2532: Object is possibly 'undefined'. 13 const header = this.document.getElementById("header"); ¿Por qué? ¿Qué debo hacer para obtener un acceso adecuado al documento? index.html para más contexto:

 <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title>Just title</title> </head> <body> <h2 id="header"></h2> <script src="app.js"></script> </body> </html>
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!