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?