#2313·yup

yup InferType works wrong with optional fields

Author: Faraz1995Created Dec 21, 2025Updated Feb 20, 2026

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