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

165
Views
Specify type as instance of a class?

I have a very specific case where I import an object containing class declarations, and I use it to create an instance as a property of another class. With class properties, I need to define a type, but when I do, the assigned type is typeof <class> instead of an instance of it (1. below).

I can get around this by assigning the prototype of the class as the type like in 2., but it feels too convoluted. Is a way to declare that the type is an instanceof the class, similar to how a type can be a typeof a class?

1. Setting type directly doesn't work

typeof foo

2. Using the class's prototype object works enter image description here

3. Works automatically for declared variables foo instance

4. Also works if the class isn't an object property enter image description here

Given that 3. works, I think the solution could be in how @type is declared, but in 4. foo's type after being imported is properly set as a class, instead of typeof foo when it's a property.

I'd appreciate the help of anyone who knows enough about JSDoc in explaining what's actually happening here, and how I can set the @type properly.

Thank you in advance.

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!