Merge pull request #32380 from sat0yu/modify-yup-array-compact

Modify the type of array.compact method in yup
This commit is contained in:
Benjamin Lichtman
2019-01-23 10:09:08 -08:00
committed by GitHub
2 changed files with 3 additions and 2 deletions
+2 -1
View File
@@ -7,6 +7,7 @@
// Yash Kulshrestha <https://github.com/YashdalfTheGray>
// Vincent Pizzo <https://github.com/vincentjames501>
// Robert Bullen <https://github.com/robertbullen>
// Yusuke Sato <https://github.com/sat0yu>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
@@ -163,7 +164,7 @@ export interface ArraySchema<T> extends Schema<T[]> {
min(limit: number | Ref, message?: TestOptionsMessage): ArraySchema<T>;
max(limit: number | Ref, message?: TestOptionsMessage): ArraySchema<T>;
ensure(): ArraySchema<T>;
compact(rejector?: (value: any) => boolean): ArraySchema<T>;
compact(rejector?: (value: T, index: number, array: T[]) => boolean): ArraySchema<T>;
}
export type ObjectSchemaDefinition<T extends object> = {
+1 -1
View File
@@ -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<string>