diff --git a/types/yup/index.d.ts b/types/yup/index.d.ts index b2939d050f..719c9c6580 100644 --- a/types/yup/index.d.ts +++ b/types/yup/index.d.ts @@ -511,5 +511,5 @@ type KeyOfUndefined = { type Id = { [K in keyof T]: T[K] }; type RequiredProps = Pick>>; type NotRequiredProps = Partial>>; -type InnerInferType = Id & RequiredProps>; +type InnerInferType = T extends Array ? T[] : Id & RequiredProps> ; type InferredArrayType = T extends Array ? U : T; diff --git a/types/yup/yup-tests.ts b/types/yup/yup-tests.ts index af6fa3fd83..e3ca4e32d3 100644 --- a/types/yup/yup-tests.ts +++ b/types/yup/yup-tests.ts @@ -823,3 +823,9 @@ function wrapper(b: boolean, msx: MixedSchema): MixedSchema { const resultingSchema1 = wrapper(false, yup.mixed().oneOf(['1', 2])); // $ExpectType MixedSchema const resultingSchema2 = wrapper(true, yup.mixed().oneOf(['1', 2])); // $ExpectType MixedSchema + +const arrayOfStringsSchema = yup.array().of(yup.string()); +type ArrayOfStrings = yup.InferType; +function returnTheArray(data: ArrayOfStrings): any[] { + return data; +}