Skip to content

[bug] typescript strictNullChecks related model type generation error. #3

@danpacho

Description

@danpacho

1. Describe the bug

Generated model and type has collision for strictNullChecks.

// Helper types for recursive schemas

export type FileModel = {
    created: number
    expires_at: number
    filename: string
    id: string
    links?: {
        data: FileLinkModel[]
        has_more: boolean
        object: 'list'
        url: string
    }
    object: 'file'
    purpose:
        | 'account_requirement'
        | 'additional_verification'
        | 'business_icon'
        | 'business_logo'
        | 'customer_signature'
        | 'dispute_evidence'
        | 'document_provider_identity_document'
        | 'finance_report_run'
        | 'financial_account_statement'
        | 'identity_document'
        | 'identity_document_downloadable'
        | 'issuing_regulatory_reporting'
        | 'pci_document'
        | 'platform_terms_of_service'
        | 'selfie'
        | 'sigma_scheduled_query'
        | 'tax_document_user_upload'
        | 'terminal_android_apk'
        | 'terminal_reader_splashscreen'
    size: number
    title: string
    type: string
    url: string
}

// Models

export const File: z.ZodType<FileModel> = z.object({
    created: z.number().int(),
    expires_at: z.number().int(),
    filename: z.string(),
    id: z.string(),
    links: z
        .object({
            data: z.array(z.lazy(() => FileLink)),
            has_more: z.boolean(),
            object: z.enum(['list']),
            url: z.string().regex(/^\/v1\/file_links/),
        })
        .optional(),
    object: z.enum(['file']),
    purpose: z.enum([
        'account_requirement',
        'additional_verification',
        'business_icon',
        'business_logo',
        'customer_signature',
        'dispute_evidence',
        'document_provider_identity_document',
        'finance_report_run',
        'financial_account_statement',
        'identity_document',
        'identity_document_downloadable',
        'issuing_regulatory_reporting',
        'pci_document',
        'platform_terms_of_service',
        'selfie',
        'sigma_scheduled_query',
        'tax_document_user_upload',
        'terminal_android_apk',
        'terminal_reader_splashscreen',
    ]),
    size: z.number().int(),
    title: z.string(),
    type: z.string(),
    url: z.string(),
})

2. Expected behavior

Should add | undefined for nullable properties.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions