Skip to content

yup InferType works wrong with optional fields #2313

Description

@Faraz1995

Describe the bug
i define schema with an optional field

` export const schema = yup.object({
aiModel: yup.string().required(),
questionFile: yup.mixed().optional(),
})

export type PriceCalculatorForm = yup.InferType`

but questionFile in PriceCalculatorForm type is not optional

here error on resolver

Type 'Resolver<{ aiModel: string; questionFile: File | undefined; }, any, { questionFile?: File | undefined; aiModel: string; }>' is not assignable to type 'Resolver<{ questionFile?: File | undefined; aiModel: string; }, any, { questionFile?: File | undefined; aiModel: string; }>'.
Types of parameters 'values' and 'values' are incompatible.
Type '{ questionFile?: File | undefined; aiModel: string; }' is not assignable to type '{aiModel: string; questionFile: File | undefined; }'.
Property 'questionFile' is optional in type '{ questionFile?: File | undefined; aiModel: string; }' but required in type '{ aiModel: string; questionFile: File | undefined; }'.

yup version 1.7.1

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions