/** * TypeScript code emitter — Declaration IR → TypeScript source code. * * Replaces `file.ts.njk` (~414 lines of Nunjucks templates) * with a typed TypeScript function that walks the FileDecl tree. * * The emitter produces correctly-formatted TypeScript code using modern * class patterns with `Partial` constructors. Output is post-processed * by prettier + eslint, so exact whitespace is not critical. * * Structural blocks emitted (in order): * 1. Header comment (auto-generated warning) * 2. Imports (LoadContext/SaveContext, referenced types) * 3. For each type in the file: * a. [abstract] class definition with extends * b. shorthandProperty static ClassVar * c. Field declarations with type annotations + defaults * d. Constructor with Partial * e. //#region Load Methods * - load() static method * - loadKind() for polymorphic dispatch (private static) * - Collection helpers (loadX / saveX) * f. //#endregion * g. //#region Save Methods * - save() instance method * - toYaml() / toJson() * - fromJson() / fromYaml() static methods * h. //#endregion * i. Factory static methods * j. Method stubs (as comments) */ import { FileDecl } from "../../ir/declarations.js"; import { ExprVisitor } from "../../ir/visitor.js"; export interface TypeScriptEmitterOptions { nativeSerialization?: "none" | "zod" | "standard-schema"; } export declare function returnType(typeStr: string): string; /** * Emit a complete TypeScript file from a FileDecl. * * @param decl - The file declaration to emit * @param visitor - Expression visitor for rendering expressions * @param namespace - Optional namespace override * @param group - Semantic group folder this file lives in (e.g. "connection"). Empty string = root. */ export declare function emitTypeScriptFile(decl: FileDecl, visitor: ExprVisitor, namespace?: string, group?: string, options?: TypeScriptEmitterOptions): string;