Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

162
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda