mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-05 23:37:04 +00:00
Make InferType from ArraySchema compatible with Array type (#42351)
This commit is contained in:
Vendored
+1
-1
@@ -511,5 +511,5 @@ type KeyOfUndefined<T> = {
|
||||
type Id<T> = { [K in keyof T]: T[K] };
|
||||
type RequiredProps<T> = Pick<T, Exclude<keyof T, KeyOfUndefined<T>>>;
|
||||
type NotRequiredProps<T> = Partial<Pick<T, KeyOfUndefined<T>>>;
|
||||
type InnerInferType<T> = Id<NotRequiredProps<T> & RequiredProps<T>>;
|
||||
type InnerInferType<T> = T extends Array<infer T> ? T[] : Id<NotRequiredProps<T> & RequiredProps<T>> ;
|
||||
type InferredArrayType<T> = T extends Array<infer U> ? U : T;
|
||||
|
||||
@@ -823,3 +823,9 @@ function wrapper<T>(b: boolean, msx: MixedSchema<T>): MixedSchema<T> {
|
||||
|
||||
const resultingSchema1 = wrapper<string | number>(false, yup.mixed().oneOf(['1', 2])); // $ExpectType MixedSchema<string | number>
|
||||
const resultingSchema2 = wrapper<string | number>(true, yup.mixed().oneOf(['1', 2])); // $ExpectType MixedSchema<string | number | null>
|
||||
|
||||
const arrayOfStringsSchema = yup.array().of(yup.string());
|
||||
type ArrayOfStrings = yup.InferType<typeof arrayOfStringsSchema>;
|
||||
function returnTheArray(data: ArrayOfStrings): any[] {
|
||||
return data;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user