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
Typescript Package Circular Reference

I am trying to create two packages with typescript (or rather, convert them to typescript. They have originally been written in javascript).

The way these packages communicate is designed like this:

The main package starts a server and then loads different extensions all of these extensions are packages which export a class that extends base_extension (the second package)

So when my users want to create an extension, they can simply init a new package, install the base_extension module, import it and extend from the default export. Easy, right?

But now with typescript I am facing an issue:

My BaseExtension class has a property server that gets set after the server has loaded the extension. In my typescript file, I of course want to use typings instead of just 'any'-ing it, so I install my main package, import the type Server and define it. No problem so far.

But in my main Package, I am also referencing extensions, so I need the typings for BaseExtension, because all extensions share a common interface (hence the inheritance). But now, when I try to build either package (with declaration export) I get the following error:

error TS5055: Cannot write file '<main_package>/lib/core/extensions/manager.d.ts' because it would overwrite input file.

I assume this error originates from me building a circular reference. Because the mentioned 'manager.d.ts' file is needed to type the base_extension package, which in turn is needed to type the main package.

Is there a correct way to deal with this problem?

I have tried removing the existing lib folder every time before I build, which avoids the error because it removes the circular reference. But that's super inconvenient because the watch option won't work. Any ideas?

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!