I have been using yup for my typescript project for a while. It requires @types/yup for the type definitions. I was using v0.26.4 of it, and it was all good. But today I update the dependency to v0.29.3. Something is wrong here:
//The object schema constructor from
<T extends object>(fields?: ObjectSchemaDefinition<T>): ObjectSchema<T>;
//changed to
<T extends object>(fields?: ObjectSchemaDefinition<T>): ObjectSchema<T | undefined>;
//then for my validation code:
const validated = await CreateNewsValidator.validate(req.body); // T | undefined
//when i use validated, the error Type 'undefined' is not assignable to type X comes
My question is when will the validate method return undefined? and what is the workaround, should i switch back to 0.26.4? Why did they make this change?