···1010 tsConfigPath: '',
1111 };
12121313- // After expansion, output should always be a single output (string or Output object)
1414- // but TypeScript doesn't know this, so we need to handle the array case defensively
1515- const singleOutput = Array.isArray(userConfig.output)
1616- ? userConfig.output[0]
1717- : userConfig.output;
1818-1919- if (typeof singleOutput === 'string') {
2020- output.path = singleOutput;
1313+ if (typeof userConfig.output === 'string') {
1414+ output.path = userConfig.output;
2115 } else {
2216 output = {
2317 ...output,
2424- ...singleOutput,
1818+ ...userConfig.output,
2519 };
2620 }
2721
+12-5
packages/openapi-ts/src/index.ts
···1414} from './error';
1515import type { IR } from './ir/types';
1616import type { Client } from './types/client';
1717-import type { Config, UserConfig } from './types/config';
1717+import type {
1818+ Config,
1919+ UserConfig,
2020+ UserConfigMultiOutputs,
2121+} from './types/config';
1822import { registerHandlebarTemplates } from './utils/handlebars';
1923import { Logger } from './utils/logger';
20242121-type ConfigValue = UserConfig | ReadonlyArray<UserConfig>;
2525+type ConfigValue =
2626+ | UserConfigMultiOutputs
2727+ | ReadonlyArray<UserConfigMultiOutputs>;
2228// Generic input shape for config that may be a value or a (possibly async) factory
2329type ConfigInput<T extends ConfigValue> = T | (() => T) | (() => Promise<T>);
2430···2733/**
2834 * Generate a client from the provided configuration.
2935 *
3030- * @param userConfig User provided {@link UserConfig} configuration.
3636+ * @param userConfig User provided {@link UserConfigMultiOutputs} configuration.
3137 */
3238export const createClient = async (
3339 userConfig?: ConfigInput<ConfigValue>,
···7985 return result;
8086 } catch (error) {
8187 const config = configs[0] as Config | undefined;
8888+ // TODO: Improve error handling for multi-output configs
8289 const resolvedSingle = (
8390 Array.isArray(resolvedConfig) ? resolvedConfig[0] : resolvedConfig
8484- ) as UserConfig | undefined;
9191+ ) as UserConfigMultiOutputs | undefined;
8592 const dryRun = config ? config.dryRun : resolvedSingle?.dryRun;
8693 const isInteractive = config
8794 ? config.interactive
8895 : resolvedSingle?.interactive;
8989- const logs = config?.logs ?? getLogs(resolvedSingle);
9696+ const logs = config?.logs ?? getLogs(resolvedSingle as UserConfig);
90979198 let logPath: string | undefined;
9299
+4-1
packages/openapi-ts/src/types/config.d.ts
···55import type { Output } from './output';
66import type { Parser, ResolvedParser } from './parser';
7788+export interface UserConfigMultiOutputs extends UserConfig {
99+ output: string | Output | ReadonlyArray<string | Output>;
1010+}
811export interface UserConfig {
912 /**
1013 * Path to the config file. Set this value if you don't use the default
···4750 * outputs to generate different versions of your SDK with different
4851 * configurations (e.g., different plugins, formatters, or paths).
4952 */
5050- output: string | Output | ReadonlyArray<string | Output>;
5353+ output: string | Output;
5154 /**
5255 * Customize how the input is parsed and transformed before it's passed to
5356 * plugins.