diff --git a/types/yup/index.d.ts b/types/yup/index.d.ts index 0afaf1fd9d..ffba765581 100644 --- a/types/yup/index.d.ts +++ b/types/yup/index.d.ts @@ -7,6 +7,7 @@ // Yash Kulshrestha // Vincent Pizzo // Robert Bullen +// Yusuke Sato // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 @@ -163,7 +164,7 @@ export interface ArraySchema extends Schema { min(limit: number | Ref, message?: TestOptionsMessage): ArraySchema; max(limit: number | Ref, message?: TestOptionsMessage): ArraySchema; ensure(): ArraySchema; - compact(rejector?: (value: any) => boolean): ArraySchema; + compact(rejector?: (value: T, index: number, array: T[]) => boolean): ArraySchema; } export type ObjectSchemaDefinition = { diff --git a/types/yup/yup-tests.ts b/types/yup/yup-tests.ts index 361cc62084..a90a7df25d 100644 --- a/types/yup/yup-tests.ts +++ b/types/yup/yup-tests.ts @@ -367,7 +367,7 @@ arrSchema.max(5, () => "max"); arrSchema.min(5); arrSchema.min(5, "min"); arrSchema.min(5, () => "min"); -arrSchema.compact(value => value === null); +arrSchema.compact((value, index, array) => value === array[index]); yup.array(); // $ExpectType ArraySchema<{}> yup.array(yup.string()); // $ExpectType ArraySchema