Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

161
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda