Circular references just output [object Object]
, in need of expert assistance
#3630
-
I am writing a custom emitter that outputs TypeSpec to Zod schemas. It's been fantastic and I've got off the ground in less than a day. However, now I need to deal with circular references. There is some documentation around this, but with that documentation in mind I simply can not figure out why the circular references will not resolve. I based my emitter closely on the test TS emitter. Theres a lot of noise in my emitter impl, and I've since realised actually, this base test emitter suffers from the same problem -- so no surprise mine does too. Using the above emitter, with a circular input like:
You'll get something like:
So let's use that as a toy. Why don't the circular references resolve? The emitter uses Edit Now I feel its worth noting I added this to my emitter and also the TS example emitter to get it to work:
And then
Possibly I have not setup the |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
I dont know why, but changing the
Im not sure what the difference is practically, but magic happened! There is a remaining issue relating to circular references of a different kind, but I will open another discussion for that If I can not figure it out. |
Beta Was this translation helpful? Give feedback.
I dont know why, but changing the
$onEmit
to the following and removingprogramContext
which I added to the emitter class) makes it work: