Describe the bug
According to the documentation, array.ensure() sets the default to [] and transforms null and undefined values to an empty array. However, the typings imply that undefined is still a possible value.
To Reproduce
import * as Yup from "yup";
const userSchema = Yup.object().shape({
array1: Yup.array().of(Yup.string().required()),
array2: Yup.array().of(Yup.string().required()).default([]),
array3: Yup.array().of(Yup.string().required()).ensure(),
});
type User = Yup.InferType<typeof userSchema>;
Actual behavior
type User = {
array1?: string[] | undefined;
array2: string[];
array3?: string[] | undefined;
}
Expected behavior
type User = {
array1?: string[] | undefined;
array2: string[];
array3: string[];
}
Describe the bug According to the documentation,
array.ensure()
sets the default to[]
and transformsnull
andundefined
values to an empty array. However, the typings imply thatundefined
is still a possible value.To Reproduce
Actual behavior
Expected behavior