Skip to content

Commit

Permalink
fix(generate-object): export result type
Browse files Browse the repository at this point in the history
  • Loading branch information
kwaa committed Feb 25, 2025
1 parent c8b26f6 commit 52ca1c2
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions packages/generate-object/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ export interface GenerateObjectOptions<T extends Schema> extends GenerateTextOpt
schemaName?: string
}

type GenerateResult<O> = GenerateTextResult & { object: O }
export type GenerateObjectResult<O> = GenerateTextResult & { object: O }

type OptionOutput = 'array' | 'object'
type GenerateObjectOutputOption = 'array' | 'object'

export async function generateObject<T extends Schema>(options: GenerateObjectOptions<T> & { output: 'array' }): Promise<GenerateResult<Array<Infer<T>>>>
export async function generateObject<T extends Schema>(options: GenerateObjectOptions<T> & { output: 'object' }): Promise<GenerateResult<Infer<T>>>
export async function generateObject<T extends Schema>(options: GenerateObjectOptions<T>): Promise<GenerateResult<Infer<T>>>
export async function generateObject<T extends Schema>(options: GenerateObjectOptions<T> & { output?: OptionOutput }) {
export async function generateObject<T extends Schema>(options: GenerateObjectOptions<T> & { output: 'array' }): Promise<GenerateObjectResult<Array<Infer<T>>>>
export async function generateObject<T extends Schema>(options: GenerateObjectOptions<T> & { output: 'object' }): Promise<GenerateObjectResult<Infer<T>>>
export async function generateObject<T extends Schema>(options: GenerateObjectOptions<T>): Promise<GenerateObjectResult<Infer<T>>>
export async function generateObject<T extends Schema>(options: GenerateObjectOptions<T> & { output?: GenerateObjectOutputOption }) {
const { schema: schemaValidator } = options

let schema = await toJSONSchema(schemaValidator)
Expand Down

0 comments on commit 52ca1c2

Please sign in to comment.