@@ -58,6 +58,23 @@ interface OpenAPIGeneratorOptions {
5858 * @default false
5959 */
6060 debug ?: boolean
61+
62+ /**
63+ * compilerOptions
64+ *
65+ * Override tsconfig.json compilerOptions
66+ */
67+ compilerOptions ?: Record < string , any >
68+
69+ /**
70+ * Temporary root
71+ *
72+ * a folder where temporary files are stored
73+ * @default os.tmpdir()/.ElysiaAutoOpenAPI
74+ *
75+ * ! be careful that the folder will be removed after the process ends
76+ */
77+ tmpRoot ?: string
6178}
6279
6380/**
@@ -80,12 +97,12 @@ export const fromTypes =
8097 instanceName,
8198 projectRoot = process . cwd ( ) ,
8299 overrideOutputPath,
83- debug = false
100+ debug = false ,
101+ compilerOptions,
102+ tmpRoot = join ( tmpdir ( ) , '.ElysiaAutoOpenAPI' )
84103 } : OpenAPIGeneratorOptions = { }
85104 ) =>
86105 ( ) => {
87- const tmpRoot = join ( tmpdir ( ) , '.ElysiaAutoOpenAPI' )
88-
89106 try {
90107 if (
91108 ! targetFilePath . endsWith ( '.ts' ) &&
@@ -128,16 +145,20 @@ export const fromTypes =
128145 join ( tmpRoot , 'tsconfig.json' ) ,
129146 `{
130147 ${ extendsRef }
131- "compilerOptions": {
132- "lib": ["ESNext"],
133- "module": "ESNext",
134- "noEmit": false,
135- "declaration": true,
136- "emitDeclarationOnly": true,
137- "moduleResolution": "bundler",
138- "skipLibCheck": true,
139- "skipDefaultLibCheck": true,
140- "outDir": "./dist"
148+ "compilerOptions": ${
149+ compilerOptions
150+ ? JSON . stringify ( compilerOptions )
151+ : `{
152+ "lib": ["ESNext"],
153+ "module": "ESNext",
154+ "noEmit": false,
155+ "declaration": true,
156+ "emitDeclarationOnly": true,
157+ "moduleResolution": "bundler",
158+ "skipLibCheck": true,
159+ "skipDefaultLibCheck": true,
160+ "outDir": "${ join ( tmpRoot , 'dist' ) } "
161+ }`
141162 } ,
142163 "include": ["${ src } "]
143164}`
0 commit comments