Recursive types and d.ts files
I'm trying to define recursive types, where there's different kind of objects. One kind is a container, which can contain any kind of those objects, including other containers. My current approach looks like this:
I'm then trying to use the inferred type to define objects in TS. This works great when doing it inside the project where I create the types and I get errors/hints/etc. (see image 1).
I also build the project into d.ts file so they can be used in another project. However, when using the type in the other project, TS seems to add an
Is there any way to prevent this or other approaches to handle this? Like, I guess if I'd have a monorepo for those projects, I could probably import the TS files directly as a type, instead of relying on the d.ts files. Is this approach also possible/recommended if I intend to publish the package that contains the arttypes?
I'm then trying to use the inferred type to define objects in TS. This works great when doing it inside the project where I create the types and I get errors/hints/etc. (see image 1).
I also build the project into d.ts file so they can be used in another project. However, when using the type in the other project, TS seems to add an
any to the type information, so that I can add any content to the container. E.g. this raises no errors (also see image 2).Is there any way to prevent this or other approaches to handle this? Like, I guess if I'd have a monorepo for those projects, I could probably import the TS files directly as a type, instead of relying on the d.ts files. Is this approach also possible/recommended if I intend to publish the package that contains the arttypes?

