Skip to content

Circular references just output [object Object], in need of expert assistance #3630

Answered by adamscybot
adamscybot asked this question in Q&A
Discussion options

You must be logged in to vote

I dont know why, but changing the $onEmit to the following and removing programContext which I added to the emitter class) makes it work:

import { EmitContext } from "@typespec/compiler";
import { TsZodSchemaEmitter } from "./zod-emitter.js";
import {
  AssetEmitter,
  createAssetEmitter,
} from "@typespec/compiler/emitter-framework";

export async function $onEmit(context: EmitContext) {
  class SingleFileEmitter extends TsZodSchemaEmitter {
    programContext() {
      const outputFile = emitter.createSourceFile("output.ts");
      return { scope: outputFile.globalScope };
    }
  }
  const emitter: AssetEmitter<string> = createAssetEmitter(
    context.program,
    SingleFileEmitter,
 …

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@bterlson
Comment options

@adamscybot
Comment options

@adamscybot
Comment options

Answer selected by adamscybot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants