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

597
Views
Using an imported type in JSDoc @typedef

I'm trying to reduce duplication in specifying my imported types as follows but I'm getting an error

/**
@typedef {import("../types/util")} util
@typedef {util.mapBehaviors} mapBehaviors
... lots of other typedefs based on util
*/
'util' only refers to a type, but is being used as a namespace here.

It's weird because expanding the import explicitly works:

/**
@typedef {import("../types/util").mapBehaviors} mapBehaviors
... lots of other typedefs
*/

How can I use @typedef with an alias of an import?

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

0

This can happen if you are only exporting interface or type from your .d.ts file and not function or const.

This will work:

/**
@typedef {import("../types/types").util} util
@typedef {util["mapBehaviors"]} mapBehaviors
...
*/

but only if in util.d.ts you have

export function mapBehaviors(tags: string[] | Behavior[], table: Behaviors): Behavior[]
...

instead of

export interface mapBehaviors {
  (tags: string[] | Behavior[], table: Behaviors): Behavior[]
}
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!