@@ -10,7 +10,7 @@ import * as afs from "node:fs/promises";
1010import * as Path from "node:path" ;
1111import { CanonicalManager } from "@atomic-ehr/fhir-canonical-manager" ;
1212import type { GeneratedFile } from "@root/api/generators/base/types" ;
13- import { CSharp } from "@root/api/writer-generator/csharp/csharp.ts " ;
13+ import { CSharp } from "@root/api/writer-generator/csharp/csharp" ;
1414import { registerFromManager } from "@root/typeschema/register" ;
1515import { mkTypeSchemaIndex , type TreeShake , treeShake } from "@root/typeschema/utils" ;
1616import { generateTypeSchemas , TypeSchemaCache , TypeSchemaGenerator , TypeSchemaParser } from "@typeschema/index" ;
@@ -19,7 +19,7 @@ import type { Config, TypeSchemaConfig } from "../config";
1919import { CodegenLogger , createLogger } from "../utils/codegen-logger" ;
2020import type { GeneratorInput } from "./generators/base/BaseGenerator" ;
2121import { TypeScriptGenerator as TypeScriptGeneratorDepricated } from "./generators/typescript" ;
22- import * as TS2 from "./writer-generator/typescript" ;
22+ import { TypeScript , type TypeScriptOptions } from "./writer-generator/typescript" ;
2323import type { Writer , WriterOptions } from "./writer-generator/writer" ;
2424
2525/**
@@ -309,19 +309,26 @@ export class APIBuilder {
309309 return this ;
310310 }
311311
312- typescript ( opts : Partial < WriterOptions > ) {
313- const writerOpts = {
312+ typescript ( userOpts : Partial < TypeScriptOptions > ) {
313+ const defaultWriterOpts : WriterOptions = {
314+ logger : this . logger ,
314315 outputDir : Path . join ( this . options . outputDir , "/types" ) ,
315316 tabSize : 4 ,
316317 withDebugComment : false ,
317318 commentLinePrefix : "//" ,
318319 generateProfile : true ,
319- exportTypeTree : this . options . exportTypeTree ,
320320 } ;
321- const effectiveOpts = { logger : this . logger , ...writerOpts , ...opts } ;
322- const generator = writerToGenerator ( new TS2 . TypeScript ( effectiveOpts ) ) ;
321+ const defaultTsOpts : TypeScriptOptions = {
322+ ...defaultWriterOpts ,
323+ openResourceTypeSet : false ,
324+ } ;
325+ const opts : TypeScriptOptions = {
326+ ...defaultTsOpts ,
327+ ...Object . fromEntries ( Object . entries ( userOpts ) . filter ( ( [ _ , v ] ) => v !== undefined ) ) ,
328+ } ;
329+ const generator = writerToGenerator ( new TypeScript ( opts ) ) ;
323330 this . generators . set ( "typescript" , generator ) ;
324- this . logger . debug ( `Configured TypeScript generator (${ JSON . stringify ( effectiveOpts , undefined , 2 ) } )` ) ;
331+ this . logger . debug ( `Configured TypeScript generator (${ JSON . stringify ( opts , undefined , 2 ) } )` ) ;
325332 return this ;
326333 }
327334
0 commit comments