Force iterators and comparators to return a value (disallow void)

This commit is contained in:
AJ Richardson
2017-10-28 10:44:16 -04:00
parent c31000f00f
commit 5cf22a50e9
2 changed files with 154 additions and 91 deletions
+83 -79
View File
@@ -1134,7 +1134,7 @@ declare namespace _ {
*/
findIndex<T>(
array: List<T> | null | undefined,
predicate?: ListIteratee<T>,
predicate?: ListIterateeBoolean<T>,
fromIndex?: number
): number;
}
@@ -1145,7 +1145,7 @@ declare namespace _ {
*/
findIndex<T>(
this: LoDashImplicitWrapper<List<T> | null | undefined>,
predicate?: ListIteratee<T>,
predicate?: ListIterateeBoolean<T>,
fromIndex?: number
): number;
}
@@ -1156,7 +1156,7 @@ declare namespace _ {
*/
findIndex<T>(
this: LoDashExplicitWrapper<List<T> | null | undefined>,
predicate?: ListIteratee<T>,
predicate?: ListIterateeBoolean<T>,
fromIndex?: number
): LoDashExplicitWrapper<number>;
}
@@ -1182,7 +1182,7 @@ declare namespace _ {
*/
findLastIndex<T>(
array: List<T> | null | undefined,
predicate?: ListIteratee<T>,
predicate?: ListIterateeBoolean<T>,
fromIndex?: number
): number;
}
@@ -1193,7 +1193,7 @@ declare namespace _ {
*/
findLastIndex<T>(
this: LoDashImplicitWrapper<List<T> | null | undefined>,
predicate?: ListIteratee<T>,
predicate?: ListIterateeBoolean<T>,
fromIndex?: number
): number;
}
@@ -1204,7 +1204,7 @@ declare namespace _ {
*/
findLastIndex<T>(
this: LoDashExplicitWrapper<List<T> | null | undefined>,
predicate?: ListIteratee<T>,
predicate?: ListIterateeBoolean<T>,
fromIndex?: number
): LoDashExplicitWrapper<number>;
}
@@ -2977,7 +2977,7 @@ declare namespace _ {
*/
uniqBy(
array: string | null | undefined,
iteratee: StringIterator<any>
iteratee: StringIterator<NotVoid>
): string[];
/**
@@ -2995,7 +2995,7 @@ declare namespace _ {
*/
uniqBy(
this: LoDashImplicitWrapper<string | null | undefined>,
iteratee: StringIterator<any>
iteratee: StringIterator<NotVoid>
): LoDashImplicitWrapper<string[]>;
/**
@@ -3013,7 +3013,7 @@ declare namespace _ {
*/
uniqBy(
this: LoDashExplicitWrapper<string | null | undefined>,
iteratee: StringIterator<any>
iteratee: StringIterator<NotVoid>
): LoDashExplicitWrapper<string[]>;
/**
@@ -3119,7 +3119,7 @@ declare namespace _ {
*/
sortedUniqBy(
array: string | null | undefined,
iteratee: StringIterator<any>
iteratee: StringIterator<NotVoid>
): string[];
/**
@@ -3137,7 +3137,7 @@ declare namespace _ {
*/
sortedUniqBy(
this: LoDashImplicitWrapper<string | null | undefined>,
iteratee: StringIterator<any>
iteratee: StringIterator<NotVoid>
): LoDashImplicitWrapper<string[]>;
/**
@@ -3155,7 +3155,7 @@ declare namespace _ {
*/
sortedUniqBy(
this: LoDashExplicitWrapper<string | null | undefined>,
iteratee: StringIterator<any>
iteratee: StringIterator<NotVoid>
): LoDashExplicitWrapper<string[]>;
/**
@@ -4227,7 +4227,7 @@ declare namespace _ {
*/
every<T>(
collection: List<T> | null | undefined,
predicate?: ListIteratee<T>
predicate?: ListIterateeBoolean<T>
): boolean;
/**
@@ -4235,7 +4235,7 @@ declare namespace _ {
*/
every<T>(
collection: NumericDictionary<T> | null | undefined,
predicate?: NumericDictionaryIteratee<T>
predicate?: NumericDictionaryIterateeBoolean<T>
): boolean;
/**
@@ -4243,7 +4243,7 @@ declare namespace _ {
*/
every<T extends object>(
collection: T | null | undefined,
predicate?: ObjectIteratee<T>
predicate?: ObjectIterateeBoolean<T>
): boolean;
}
@@ -4253,7 +4253,7 @@ declare namespace _ {
*/
every<T>(
this: LoDashImplicitWrapper<List<T> | null | undefined>,
predicate?: ListIteratee<T>
predicate?: ListIterateeBoolean<T>
): boolean;
/**
@@ -4261,7 +4261,7 @@ declare namespace _ {
*/
every<T extends object>(
this: LoDashImplicitWrapper<T | null | undefined>,
predicate?: ObjectIteratee<T>
predicate?: ObjectIterateeBoolean<T>
): boolean;
/**
@@ -4269,7 +4269,7 @@ declare namespace _ {
*/
every<T>(
this: LoDashImplicitWrapper<NumericDictionary<T> | null | undefined>,
predicate?: NumericDictionaryIteratee<T>
predicate?: NumericDictionaryIterateeBoolean<T>
): boolean;
}
@@ -4279,7 +4279,7 @@ declare namespace _ {
*/
every<T>(
this: LoDashExplicitWrapper<List<T> | null | undefined>,
predicate?: ListIteratee<T>
predicate?: ListIterateeBoolean<T>
): LoDashExplicitWrapper<boolean>;
/**
@@ -4287,7 +4287,7 @@ declare namespace _ {
*/
every<T extends object>(
this: LoDashExplicitWrapper<T | null | undefined>,
predicate?: ObjectIteratee<T>
predicate?: ObjectIterateeBoolean<T>
): LoDashExplicitWrapper<boolean>;
/**
@@ -4295,7 +4295,7 @@ declare namespace _ {
*/
every<T>(
this: LoDashExplicitWrapper<NumericDictionary<T> | null | undefined>,
predicate?: NumericDictionaryIteratee<T>
predicate?: NumericDictionaryIterateeBoolean<T>
): LoDashExplicitWrapper<boolean>;
}
@@ -4321,7 +4321,7 @@ declare namespace _ {
*/
filter(
collection: string | null | undefined,
predicate?: StringIterator<any>
predicate?: StringIterator<boolean | null | undefined>
): string[];
/**
@@ -4337,7 +4337,7 @@ declare namespace _ {
*/
filter<T>(
collection: List<T> | null | undefined,
predicate?: ListIteratee<T>
predicate?: ListIterateeBoolean<T>
): T[];
/**
@@ -4353,7 +4353,7 @@ declare namespace _ {
*/
filter<T extends object>(
collection: T | null | undefined,
predicate?: ObjectIteratee<T>
predicate?: ObjectIterateeBoolean<T>
): Array<T[keyof T]>;
}
@@ -4363,7 +4363,7 @@ declare namespace _ {
*/
filter(
this: LoDashImplicitWrapper<string | null | undefined>,
predicate?: StringIterator<any>
predicate?: StringIterator<boolean | null | undefined>
): LoDashImplicitWrapper<string[]>;
/**
@@ -4379,7 +4379,7 @@ declare namespace _ {
*/
filter<T>(
this: LoDashImplicitWrapper<List<T> | null | undefined>,
predicate?: ListIteratee<T>
predicate?: ListIterateeBoolean<T>
): LoDashImplicitWrapper<T[]>;
/**
@@ -4395,7 +4395,7 @@ declare namespace _ {
*/
filter<T extends object>(
this: LoDashImplicitWrapper<T | null | undefined>,
predicate?: ObjectIteratee<T>
predicate?: ObjectIterateeBoolean<T>
): LoDashImplicitWrapper<Array<T[keyof T]>>;
}
@@ -4405,7 +4405,7 @@ declare namespace _ {
*/
filter(
this: LoDashExplicitWrapper<string | null | undefined>,
predicate?: StringIterator<any>
predicate?: StringIterator<boolean | null | undefined>
): LoDashExplicitWrapper<string[]>;
/**
@@ -4421,7 +4421,7 @@ declare namespace _ {
*/
filter<T>(
this: LoDashExplicitWrapper<List<T> | null | undefined>,
predicate?: ListIteratee<T>
predicate?: ListIterateeBoolean<T>
): LoDashExplicitWrapper<T[]>;
/**
@@ -4437,7 +4437,7 @@ declare namespace _ {
*/
filter<T extends object>(
this: LoDashExplicitWrapper<T | null | undefined>,
predicate?: ObjectIteratee<T>
predicate?: ObjectIterateeBoolean<T>
): LoDashExplicitWrapper<Array<T[keyof T]>>;
}
@@ -4472,7 +4472,7 @@ declare namespace _ {
*/
find<T>(
collection: List<T> | null | undefined,
predicate?: ListIteratee<T>,
predicate?: ListIterateeBoolean<T>,
fromIndex?: number
): T|undefined;
@@ -4490,7 +4490,7 @@ declare namespace _ {
*/
find<T extends object>(
collection: T | null | undefined,
predicate?: ObjectIteratee<T>,
predicate?: ObjectIterateeBoolean<T>,
fromIndex?: number
): T[keyof T]|undefined;
}
@@ -4510,7 +4510,7 @@ declare namespace _ {
*/
find<T>(
this: LoDashImplicitWrapper<List<T> | null | undefined>,
predicate?: ListIteratee<T>,
predicate?: ListIterateeBoolean<T>,
fromIndex?: number
): T|undefined;
@@ -4528,7 +4528,7 @@ declare namespace _ {
*/
find<T extends object>(
this: LoDashImplicitWrapper<T | null | undefined>,
predicate?: ObjectIteratee<T>,
predicate?: ObjectIterateeBoolean<T>,
fromIndex?: number
): T[keyof T]|undefined;
}
@@ -4548,7 +4548,7 @@ declare namespace _ {
*/
find<T>(
this: LoDashExplicitWrapper<List<T> | null | undefined>,
predicate?: ListIteratee<T>,
predicate?: ListIterateeBoolean<T>,
fromIndex?: number
): LoDashExplicitWrapper<T|undefined>;
@@ -4566,7 +4566,7 @@ declare namespace _ {
*/
find<T extends object>(
this: LoDashExplicitWrapper<T | null | undefined>,
predicate?: ObjectIteratee<T>,
predicate?: ObjectIterateeBoolean<T>,
fromIndex?: number
): LoDashExplicitWrapper<T[keyof T]|undefined>;
}
@@ -4592,7 +4592,7 @@ declare namespace _ {
*/
findLast<T>(
collection: List<T> | null | undefined,
predicate?: ListIteratee<T>,
predicate?: ListIterateeBoolean<T>,
fromIndex?: number
): T|undefined;
@@ -4610,7 +4610,7 @@ declare namespace _ {
*/
findLast<T extends object>(
collection: T | null | undefined,
predicate?: ObjectIteratee<T>,
predicate?: ObjectIterateeBoolean<T>,
fromIndex?: number
): T[keyof T]|undefined;
}
@@ -4630,7 +4630,7 @@ declare namespace _ {
*/
findLast<T>(
this: LoDashImplicitWrapper<List<T> | null | undefined>,
predicate?: ListIteratee<T>,
predicate?: ListIterateeBoolean<T>,
fromIndex?: number
): T | undefined;
@@ -4648,7 +4648,7 @@ declare namespace _ {
*/
findLast<T extends object>(
this: LoDashImplicitWrapper<T | null | undefined>,
predicate?: ObjectIteratee<T>,
predicate?: ObjectIterateeBoolean<T>,
fromIndex?: number
): T[keyof T]|undefined;
}
@@ -4668,7 +4668,7 @@ declare namespace _ {
*/
findLast<T>(
this: LoDashExplicitWrapper<List<T> | null | undefined>,
predicate?: ListIteratee<T>,
predicate?: ListIterateeBoolean<T>,
fromIndex?: number
): LoDashExplicitWrapper<T | undefined>;
@@ -4686,7 +4686,7 @@ declare namespace _ {
*/
findLast<T extends object>(
this: LoDashExplicitWrapper<T | null | undefined>,
predicate?: ObjectIteratee<T>,
predicate?: ObjectIterateeBoolean<T>,
fromIndex?: number
): LoDashExplicitWrapper<T[keyof T]|undefined>;
}
@@ -5439,7 +5439,7 @@ declare namespace _ {
*/
groupBy(
collection: string | null | undefined,
iteratee?: StringIterator<any>
iteratee?: StringIterator<NotVoid>
): Dictionary<string[]>;
/**
@@ -5473,7 +5473,7 @@ declare namespace _ {
*/
groupBy(
this: LoDashImplicitWrapper<string | null | undefined>,
iteratee?: StringIterator<any>
iteratee?: StringIterator<NotVoid>
): LoDashImplicitWrapper<Dictionary<string[]>>;
/**
@@ -5507,7 +5507,7 @@ declare namespace _ {
*/
groupBy(
this: LoDashExplicitWrapper<string | null | undefined>,
iteratee?: StringIterator<any>
iteratee?: StringIterator<NotVoid>
): LoDashExplicitWrapper<Dictionary<string[]>>;
/**
@@ -6458,7 +6458,7 @@ declare namespace _ {
*/
reject(
collection: string | null | undefined,
predicate?: StringIterator<any>
predicate?: StringIterator<boolean | null | undefined>
): string[];
/**
@@ -6466,7 +6466,7 @@ declare namespace _ {
*/
reject<T>(
collection: List<T> | null | undefined,
predicate?: ListIteratee<T>
predicate?: ListIterateeBoolean<T>
): T[];
/**
@@ -6474,7 +6474,7 @@ declare namespace _ {
*/
reject<T extends object>(
collection: T | null | undefined,
predicate?: ObjectIteratee<T>
predicate?: ObjectIterateeBoolean<T>
): Array<T[keyof T]>;
}
@@ -6484,7 +6484,7 @@ declare namespace _ {
*/
reject(
this: LoDashImplicitWrapper<string | null | undefined>,
predicate?: StringIterator<any>
predicate?: StringIterator<boolean | null | undefined>
): LoDashImplicitWrapper<string[]>;
/**
@@ -6492,7 +6492,7 @@ declare namespace _ {
*/
reject<T>(
this: LoDashImplicitWrapper<List<T> | null | undefined>,
predicate?: ListIteratee<T>
predicate?: ListIterateeBoolean<T>
): LoDashImplicitWrapper<T[]>;
/**
@@ -6500,7 +6500,7 @@ declare namespace _ {
*/
reject<T extends object>(
this: LoDashImplicitWrapper<T | null | undefined>,
predicate?: ObjectIteratee<T>
predicate?: ObjectIterateeBoolean<T>
): LoDashImplicitWrapper<Array<T[keyof T]>>;
}
@@ -6510,7 +6510,7 @@ declare namespace _ {
*/
reject(
this: LoDashExplicitWrapper<string | null | undefined>,
predicate?: StringIterator<any>
predicate?: StringIterator<boolean | null | undefined>
): LoDashExplicitWrapper<string[]>;
/**
@@ -6518,7 +6518,7 @@ declare namespace _ {
*/
reject<T>(
this: LoDashExplicitWrapper<List<T> | null | undefined>,
predicate?: ListIteratee<T>
predicate?: ListIterateeBoolean<T>
): LoDashExplicitWrapper<T[]>;
/**
@@ -6526,7 +6526,7 @@ declare namespace _ {
*/
reject<T extends object>(
this: LoDashExplicitWrapper<T | null | undefined>,
predicate?: ObjectIteratee<T>
predicate?: ObjectIterateeBoolean<T>
): LoDashExplicitWrapper<Array<T[keyof T]>>;
}
@@ -6740,7 +6740,7 @@ declare namespace _ {
*/
some<T>(
collection: List<T> | null | undefined,
predicate?: ListIteratee<T>
predicate?: ListIterateeBoolean<T>
): boolean;
/**
@@ -6748,7 +6748,7 @@ declare namespace _ {
*/
some<T extends object>(
collection: T | null | undefined,
predicate?: ObjectIteratee<T>
predicate?: ObjectIterateeBoolean<T>
): boolean;
/**
@@ -6756,7 +6756,7 @@ declare namespace _ {
*/
some<T>(
collection: NumericDictionary<T> | null | undefined,
predicate?: NumericDictionaryIteratee<T>
predicate?: NumericDictionaryIterateeBoolean<T>
): boolean;
}
@@ -6766,7 +6766,7 @@ declare namespace _ {
*/
some<T>(
this: LoDashImplicitWrapper<List<T> | null | undefined>,
predicate?: ListIteratee<T>
predicate?: ListIterateeBoolean<T>
): boolean;
/**
@@ -6774,7 +6774,7 @@ declare namespace _ {
*/
some<T extends object>(
this: LoDashImplicitWrapper<T | null | undefined>,
predicate?: ObjectIteratee<T>
predicate?: ObjectIterateeBoolean<T>
): boolean;
/**
@@ -6782,7 +6782,7 @@ declare namespace _ {
*/
some<T>(
this: LoDashImplicitWrapper<NumericDictionary<T> | null | undefined>,
predicate?: NumericDictionaryIteratee<T>
predicate?: NumericDictionaryIterateeBoolean<T>
): boolean;
}
@@ -6792,7 +6792,7 @@ declare namespace _ {
*/
some<T>(
this: LoDashExplicitWrapper<List<T> | null | undefined>,
predicate?: ListIteratee<T>
predicate?: ListIterateeBoolean<T>
): LoDashExplicitWrapper<boolean>;
/**
@@ -6800,7 +6800,7 @@ declare namespace _ {
*/
some<T extends object>(
this: LoDashExplicitWrapper<T | null | undefined>,
predicate?: ObjectIteratee<T>
predicate?: ObjectIterateeBoolean<T>
): LoDashExplicitWrapper<boolean>;
/**
@@ -6808,7 +6808,7 @@ declare namespace _ {
*/
some<T>(
this: LoDashExplicitWrapper<NumericDictionary<T> | null | undefined>,
predicate?: NumericDictionaryIteratee<T>
predicate?: NumericDictionaryIterateeBoolean<T>
): LoDashExplicitWrapper<boolean>;
}
@@ -6924,7 +6924,7 @@ declare namespace _ {
*/
orderBy<T>(
collection: List<T> | null | undefined,
iteratees?: Many<ListIterator<T, any>>,
iteratees?: Many<ListIterator<T, NotVoid>>,
orders?: Many<boolean|string>
): T[];
@@ -6942,7 +6942,7 @@ declare namespace _ {
*/
orderBy<T extends object>(
collection: T | null | undefined,
iteratees?: Many<ObjectIterator<T, any>>,
iteratees?: Many<ObjectIterator<T, NotVoid>>,
orders?: Many<boolean|string>
): Array<T[keyof T]>;
@@ -6960,7 +6960,7 @@ declare namespace _ {
*/
orderBy<T>(
collection: NumericDictionary<T> | null | undefined,
iteratees?: Many<NumericDictionaryIterator<T, any>>,
iteratees?: Many<NumericDictionaryIterator<T, NotVoid>>,
orders?: Many<boolean|string>
): T[];
@@ -6980,7 +6980,7 @@ declare namespace _ {
*/
orderBy<T>(
this: LoDashImplicitWrapper<List<T> | null | undefined>,
iteratees?: Many<ListIterator<T, any>>,
iteratees?: Many<ListIterator<T, NotVoid>>,
orders?: Many<boolean|string>
): LoDashImplicitWrapper<T[]>;
@@ -6998,7 +6998,7 @@ declare namespace _ {
*/
orderBy<T extends object>(
this: LoDashImplicitWrapper<T | null | undefined>,
iteratees?: Many<ObjectIterator<T, any>>,
iteratees?: Many<ObjectIterator<T, NotVoid>>,
orders?: Many<boolean|string>
): LoDashImplicitWrapper<Array<T[keyof T]>>;
@@ -7016,7 +7016,7 @@ declare namespace _ {
*/
orderBy<T>(
this: LoDashImplicitWrapper<NumericDictionary<T> | null | undefined>,
iteratees?: Many<NumericDictionaryIterator<T, any>>,
iteratees?: Many<NumericDictionaryIterator<T, NotVoid>>,
orders?: Many<boolean|string>
): LoDashImplicitWrapper<T[]>;
@@ -7036,7 +7036,7 @@ declare namespace _ {
*/
orderBy<T>(
this: LoDashExplicitWrapper<List<T> | null | undefined>,
iteratees?: Many<ListIterator<T, any>>,
iteratees?: Many<ListIterator<T, NotVoid>>,
orders?: Many<boolean|string>
): LoDashExplicitWrapper<T[]>;
@@ -7054,7 +7054,7 @@ declare namespace _ {
*/
orderBy<T extends object>(
this: LoDashExplicitWrapper<T | null | undefined>,
iteratees?: Many<ObjectIterator<T, any>>,
iteratees?: Many<ObjectIterator<T, NotVoid>>,
orders?: Many<boolean|string>
): LoDashExplicitWrapper<Array<T[keyof T]>>;
@@ -7072,7 +7072,7 @@ declare namespace _ {
*/
orderBy<T>(
this: LoDashExplicitWrapper<NumericDictionary<T> | null | undefined>,
iteratees?: Many<NumericDictionaryIterator<T, any>>,
iteratees?: Many<NumericDictionaryIterator<T, NotVoid>>,
orders?: Many<boolean|string>
): LoDashExplicitWrapper<T[]>;
@@ -16589,14 +16589,17 @@ declare namespace _ {
uniqueId(): LoDashExplicitWrapper<string>;
}
type NotVoid = {} | null | undefined;
type ArrayIterator<T, TResult> = (value: T, index: number, collection: T[]) => TResult;
type ListIterator<T, TResult> = (value: T, index: number, collection: List<T>) => TResult;
type ListIteratee<T> = ListIterator<T, any> | string | [string, any] | PartialDeep<T>;
type ListIteratee<T> = ListIterator<T, NotVoid> | string | [string, any] | PartialDeep<T>;
type ListIterateeBoolean<T> = ListIterator<T, boolean | null | undefined> | string | [string, any] | PartialDeep<T>;
type ListIteratorTypeGuard<T, S extends T> = (value: T, index: number, collection: List<T>) => value is S;
// Note: key should be string, not keyof T, because the actual object may contain extra properties that were not specified in the type.
type ObjectIterator<TObject, TResult> = (value: TObject[keyof TObject], key: string, collection: TObject) => TResult;
type ObjectIteratee<TObject> = ObjectIterator<TObject, any> | string | [string, any] | PartialDeep<TObject[keyof TObject]>;
type ObjectIteratee<TObject> = ObjectIterator<TObject, NotVoid> | string | [string, any] | PartialDeep<TObject[keyof TObject]>;
type ObjectIterateeBoolean<TObject> = ObjectIterator<TObject, boolean | null | undefined> | string | [string, any] | PartialDeep<TObject[keyof TObject]>;
type ObjectIteratorTypeGuard<TObject, S extends TObject[keyof TObject]> = (value: TObject[keyof TObject], key: string, collection: TObject) => value is S;
type DictionaryIterator<T, TResult> = ObjectIterator<Dictionary<T>, TResult>;
@@ -16604,7 +16607,8 @@ declare namespace _ {
type DictionaryIteratorTypeGuard<T, S extends T> = ObjectIteratorTypeGuard<Dictionary<T>, S>;
type NumericDictionaryIterator<T, TResult> = (value: T, key: number, collection: NumericDictionary<T>) => TResult;
type NumericDictionaryIteratee<T> = NumericDictionaryIterator<T, any> | string | [string, any] | PartialDeep<T>;
type NumericDictionaryIteratee<T> = NumericDictionaryIterator<T, NotVoid> | string | [string, any] | PartialDeep<T>;
type NumericDictionaryIterateeBoolean<T> = NumericDictionaryIterator<T, boolean | null | undefined> | string | [string, any] | PartialDeep<T>;
type StringIterator<TResult> = (char: string, index: number, string: string) => TResult;
@@ -16618,10 +16622,10 @@ declare namespace _ {
type MemoVoidArrayIterator<T, TResult> = (acc: TResult, curr: T, index: number, arr: T[]) => void;
type MemoVoidDictionaryIterator<T, TResult> = (acc: TResult, curr: T, key: string, dict: Dictionary<T>) => void;
type ValueIteratee<T> = ((value: T) => any) | string | [string, any] | PartialDeep<T>;
type ValueKeyIteratee<T> = ((value: T, key: string) => any) | string | [string, any] | PartialDeep<T>;
type Comparator<T> = (a: T, b: T) => any;
type Comparator2<T1, T2> = (a: T1, b: T2) => any;
type ValueIteratee<T> = ((value: T) => NotVoid) | string | [string, any] | PartialDeep<T>;
type ValueKeyIteratee<T> = ((value: T, key: string) => NotVoid) | string | [string, any] | PartialDeep<T>;
type Comparator<T> = (a: T, b: T) => boolean | null | undefined;
type Comparator2<T1, T2> = (a: T1, b: T2) => boolean | null | undefined;
type PropertyName = string | number;
type PropertyPath = Many<PropertyName>;
+71 -12
View File
@@ -504,30 +504,37 @@ namespace TestDifferenceBy {
// $ExpectType T1[]
_.differenceBy([t1], [t2], (value) => {
value; // $ExpectType T1 | T2
return 0;
});
// $ExpectType T1[]
_.differenceBy([t1], [t2, t3], (value) => {
value; // $ExpectType T1 | T2 | T3
return 0;
});
// $ExpectType (T1 | T2)[]
_.differenceBy([t1, t2], [t3], (value) => {
value; // $ExpectType T1 | T2 | T3
return 0;
});
// $ExpectType T1[]
_.differenceBy([t1], [t2], [t3], (value) => {
value; // $ExpectType T1 | T2 | T3
return 0;
});
// $ExpectType T1[]
_.differenceBy([t1], [t2], [t3], [t4], (value) => {
value; // $ExpectType T1 | T2 | T3 | T4
return 0;
});
// $ExpectType T1[]
_.differenceBy([t1], [t2], [t3], [t4], [''], (value) => {
value; // $ExpectType string | T1 | T2 | T3 | T4
return 0;
});
// $ExpectType T1[]
_.differenceBy([t1], [t2], [t3], [t4], [''], [42], (value) => {
value; // $ExpectType string | number | T1 | T2 | T3 | T4
return 0;
});
// $ExpectType LoDashImplicitWrapper<T1[]>
@@ -535,30 +542,37 @@ namespace TestDifferenceBy {
// $ExpectType LoDashImplicitWrapper<T1[]>
_([t1]).differenceBy([t2], (value) => {
value; // $ExpectType T1 | T2
return 0;
});
// $ExpectType LoDashImplicitWrapper<T1[]>
_([t1]).differenceBy([t2, t3], (value) => {
value; // $ExpectType T1 | T2 | T3
return 0;
});
// $ExpectType LoDashImplicitWrapper<(T1 | T2)[]>
_([t1, t2]).differenceBy([t3], (value) => {
value; // $ExpectType T1 | T2 | T3
return 0;
});
// $ExpectType LoDashImplicitWrapper<T1[]>
_([t1]).differenceBy([t2], [t3], (value) => {
value; // $ExpectType T1 | T2 | T3
return 0;
});
// $ExpectType LoDashImplicitWrapper<T1[]>
_([t1]).differenceBy([t2], [t3], [t4], (value) => {
value; // $ExpectType T1 | T2 | T3 | T4
return 0;
});
// $ExpectType LoDashImplicitWrapper<T1[]>
_([t1]).differenceBy([t2], [t3], [t4], [''], (value) => {
value; // $ExpectType string | T1 | T2 | T3 | T4
return 0;
});
// $ExpectType LoDashImplicitWrapper<T1[]>
_([t1]).differenceBy([t2], [t3], [t4], [''], [42], (value) => {
value; // $ExpectType string | number | T1 | T2 | T3 | T4
return 0;
});
// $ExpectType LoDashExplicitWrapper<T1[]>
@@ -566,30 +580,37 @@ namespace TestDifferenceBy {
// $ExpectType LoDashExplicitWrapper<T1[]>
_.chain([t1]).differenceBy([t2], (value) => {
value; // $ExpectType T1 | T2
return 0;
});
// $ExpectType LoDashExplicitWrapper<T1[]>
_.chain([t1]).differenceBy([t2, t3], (value) => {
value; // $ExpectType T1 | T2 | T3
return 0;
});
// $ExpectType LoDashExplicitWrapper<(T1 | T2)[]>
_.chain([t1, t2]).differenceBy([t3], (value) => {
value; // $ExpectType T1 | T2 | T3
return 0;
});
// $ExpectType LoDashExplicitWrapper<T1[]>
_.chain([t1]).differenceBy([t2], [t3], (value) => {
value; // $ExpectType T1 | T2 | T3
return 0;
});
// $ExpectType LoDashExplicitWrapper<T1[]>
_.chain([t1]).differenceBy([t2], [t3], [t4], (value) => {
value; // $ExpectType T1 | T2 | T3 | T4
return 0;
});
// $ExpectType LoDashExplicitWrapper<T1[]>
_.chain([t1]).differenceBy([t2], [t3], [t4], [''], (value) => {
value; // $ExpectType string | T1 | T2 | T3 | T4
return 0;
});
// $ExpectType LoDashExplicitWrapper<T1[]>
_.chain([t1]).differenceBy([t2], [t3], [t4], [''], [42], (value) => {
value; // $ExpectType string | number | T1 | T2 | T3 | T4
return 0;
});
}
}
@@ -600,7 +621,7 @@ namespace TestDifferenceBy {
let list: _.List<TResult> | null | undefined = [] as any;
let arrayParam: TResult[] = [];
let listParam: _.List<TResult> = [];
let comparator = (a: TResult, b: TResult) => any;
let comparator = (a: TResult, b: TResult) => true;
{
// $ExpectType TResult[]
@@ -678,6 +699,7 @@ namespace TestDifferenceBy {
_.differenceWith([t1], [t2], (a, b) => {
a; // $ExpectType T1
b; // $ExpectType T2 | undefined
return true;
});
// $ExpectType LoDashImplicitWrapper<T1[]>
@@ -686,6 +708,7 @@ namespace TestDifferenceBy {
_([t1]).differenceWith([t2], (a, b) => {
a; // $ExpectType T1
b; // $ExpectType T2 | undefined
return true;
});
// $ExpectType LoDashExplicitWrapper<T1[]>
@@ -694,6 +717,7 @@ namespace TestDifferenceBy {
_.chain([t1]).differenceWith([t2], (a, b) => {
a; // $ExpectType T1
b; // $ExpectType T2 | undefined
return true;
});
}
}
@@ -1459,10 +1483,12 @@ namespace TestIntersection {
// $ExpectType TResult[]
result = _.intersectionBy(array, list, (value) => {
value; // $ExpectType TResult
return 0;
});
// $ExpectType TResult[]
result = _.intersectionBy(list, array, list, (value) => {
value; // $ExpectType TResult
return 0;
});
// $ExpectType LoDashImplicitWrapper<TResult[]>
@@ -1480,10 +1506,12 @@ namespace TestIntersection {
// $ExpectType LoDashImplicitWrapper<TResult[]>
result = _(array).intersectionBy(list, (value) => {
value; // $ExpectType TResult
return "";
});
// $ExpectType LoDashImplicitWrapper<TResult[]>
result = _(list).intersectionBy(array, list, (value) => {
value; // $ExpectType TResult
return 1;
});
// $ExpectType LoDashExplicitWrapper<TResult[]>
@@ -1501,10 +1529,12 @@ namespace TestIntersection {
// $ExpectType LoDashExplicitWrapper<TResult[]>
result = _.chain(array).intersectionBy(list, (value) => {
value; // $ExpectType TResult
return false;
});
// $ExpectType LoDashExplicitWrapper<TResult[]>
result = _.chain(list).intersectionBy(array, list, (value) => {
value; // $ExpectType TResult
return null;
});
interface T1 {
@@ -1520,14 +1550,17 @@ namespace TestIntersection {
// $ExpectType T1[]
result = _.intersectionBy([t1], [t2], (value) => {
value; // $ExpectType T1 | T2
return undefined;
});
// $ExpectType LoDashImplicitWrapper<T1[]>
result = _([t1]).intersectionBy([t2], (value) => {
value; // $ExpectType T1 | T2
return {};
});
// $ExpectType LoDashExplicitWrapper<T1[]>
result = _.chain([t1]).intersectionBy([t2], (value) => {
value; // $ExpectType T1 | T2
return {};
});
}
@@ -1546,11 +1579,13 @@ namespace TestIntersection {
result = _.intersectionWith(array, list, (a, b) => {
a; // $ExpectType TResult
b; // $ExpectType TResult
return true;
});
// $ExpectType TResult[]
result = _.intersectionWith(list, array, list, (a, b) => {
a; // $ExpectType TResult
b; // $ExpectType TResult
return true;
});
// $ExpectType LoDashImplicitWrapper<TResult[]>
@@ -1561,11 +1596,13 @@ namespace TestIntersection {
result = _(array).intersectionWith(list, (a, b) => {
a; // $ExpectType TResult
b; // $ExpectType TResult
return true;
});
// $ExpectType LoDashImplicitWrapper<TResult[]>
result = _(list).intersectionWith(array, list, (a, b) => {
a; // $ExpectType TResult
b; // $ExpectType TResult
return true;
});
// $ExpectType LoDashExplicitWrapper<TResult[]>
@@ -1576,11 +1613,13 @@ namespace TestIntersection {
result = _.chain(array).intersectionWith(list, (a, b) => {
a; // $ExpectType TResult
b; // $ExpectType TResult
return true;
});
// $ExpectType LoDashExplicitWrapper<TResult[]>
result = _.chain(list).intersectionWith(array, list, (a, b) => {
a; // $ExpectType TResult
b; // $ExpectType TResult
return true;
});
interface T1 {
@@ -1597,16 +1636,19 @@ namespace TestIntersection {
result = _.intersectionWith([t1], [t2], (a, b) => {
a; // $ExpectType T1
b; // $ExpectType T2
return true;
});
// $ExpectType LoDashImplicitWrapper<T1[]>
result = _([t1]).intersectionWith([t2], (a, b) => {
a; // $ExpectType T1
b; // $ExpectType T2
return true;
});
// $ExpectType LoDashExplicitWrapper<T1[]>
result = _.chain([t1]).intersectionWith([t2], (a, b) => {
a; // $ExpectType T1
b; // $ExpectType T2
return true;
});
}
@@ -1936,6 +1978,7 @@ namespace TestPullAt {
// $ExpectType TResult[]
_.pullAllBy(array, values, (value) => {
value; // $ExpectType TResult
return [];
});
// $ExpectType ArrayLike<TResult>
_.pullAllBy(list);
@@ -1950,6 +1993,7 @@ namespace TestPullAt {
// $ExpectType ArrayLike<TResult>
_.pullAllBy(list, values, (value) => {
value; // $ExpectType TResult
return () => {};
});
// $ExpectType LoDashImplicitWrapper<TResult[]>
@@ -1965,6 +2009,7 @@ namespace TestPullAt {
// $ExpectType LoDashImplicitWrapper<TResult[]>
_(array).pullAllBy(values, (value) => {
value; // $ExpectType TResult
return 0;
});
// $ExpectType LoDashImplicitWrapper<ArrayLike<TResult>>
_(list).pullAllBy();
@@ -1979,6 +2024,7 @@ namespace TestPullAt {
// $ExpectType LoDashImplicitWrapper<ArrayLike<TResult>>
_(list).pullAllBy(values, (value) => {
value; // $ExpectType TResult
return 0;
});
// $ExpectType LoDashExplicitWrapper<TResult[]>
@@ -1994,6 +2040,7 @@ namespace TestPullAt {
// $ExpectType LoDashExplicitWrapper<TResult[]>
_.chain(array).pullAllBy(values, (value) => {
value; // $ExpectType TResult
return 0;
});
// $ExpectType LoDashExplicitWrapper<ArrayLike<TResult>>
_.chain(list).pullAllBy();
@@ -2008,6 +2055,7 @@ namespace TestPullAt {
// $ExpectType LoDashExplicitWrapper<ArrayLike<TResult>>
_.chain(list).pullAllBy(values, (value) => {
value; // $ExpectType TResult
return 0;
});
interface T1 {
@@ -2023,14 +2071,17 @@ namespace TestPullAt {
// $ExpectType T1[]
result = _.pullAllBy([t1], [t2], (value) => {
value; // $ExpectType T1 | T2
return "";
});
// $ExpectType LoDashImplicitWrapper<T1[]>
result = _([t1]).pullAllBy([t2], (value) => {
value; // $ExpectType T1 | T2
return "";
});
// $ExpectType LoDashExplicitWrapper<T1[]>
result = _.chain([t1]).pullAllBy([t2], (value) => {
value; // $ExpectType T1 | T2
return "";
});
}
@@ -2048,6 +2099,7 @@ namespace TestPullAt {
_.pullAllWith(array, values, (a, b) => {
a; // $ExpectType TResult
b; // $ExpectType TResult
return true;
});
// $ExpectType ArrayLike<TResult>
_.pullAllWith(list);
@@ -2057,6 +2109,7 @@ namespace TestPullAt {
_.pullAllWith(list, values, (a, b) => {
a; // $ExpectType TResult
b; // $ExpectType TResult
return true;
});
// $ExpectType LoDashImplicitWrapper<TResult[]>
@@ -2067,6 +2120,7 @@ namespace TestPullAt {
_(array).pullAllWith(values, (a, b) => {
a; // $ExpectType TResult
b; // $ExpectType TResult
return true;
});
// $ExpectType LoDashImplicitWrapper<ArrayLike<TResult>>
_(list).pullAllWith();
@@ -2076,6 +2130,7 @@ namespace TestPullAt {
_(list).pullAllWith(values, (a, b) => {
a; // $ExpectType TResult
b; // $ExpectType TResult
return true;
});
// $ExpectType LoDashExplicitWrapper<TResult[]>
@@ -2086,6 +2141,7 @@ namespace TestPullAt {
_.chain(array).pullAllWith(values, (a, b) => {
a; // $ExpectType TResult
b; // $ExpectType TResult
return true;
});
// $ExpectType LoDashExplicitWrapper<ArrayLike<TResult>>
_.chain(list).pullAllWith();
@@ -2095,6 +2151,7 @@ namespace TestPullAt {
_.chain(list).pullAllWith(values, (a, b) => {
a; // $ExpectType TResult
b; // $ExpectType TResult
return true;
});
interface T1 {
@@ -2111,16 +2168,19 @@ namespace TestPullAt {
result = _.pullAllWith([t1], [t2], (a, b) => {
a; // $ExpectType T1
b; // $ExpectType T2
return true;
});
// $ExpectType LoDashImplicitWrapper<T1[]>
result = _([t1]).pullAllWith([t2], (a, b) => {
a; // $ExpectType T1
b; // $ExpectType T2
return true;
});
// $ExpectType LoDashExplicitWrapper<T1[]>
result = _.chain([t1]).pullAllWith([t2], (a, b) => {
a; // $ExpectType T1
b; // $ExpectType T2
return true;
});
}
@@ -6867,12 +6927,11 @@ result = <IFoodOrganic[]>_(foodsOrganic).sortBy('organic', (food) => food.name,
namespace TestorderBy {
type SampleObject = {a: number; b: string; c: boolean};
let array: SampleObject[] | null | undefined = [] as any;
let list: _.List<SampleObject> | null | undefined = [] as any;
let obj: any = {};
let numericDictionary: _.NumericDictionary<SampleObject> | null | undefined = obj;
let dictionary: _.Dictionary<SampleObject> | null | undefined = obj;
let orders: boolean|string|(boolean|string)[] = true as any;
const array: SampleObject[] | null | undefined = any;
const list: _.List<SampleObject> | null | undefined = any;
const numericDictionary: _.NumericDictionary<SampleObject> | null | undefined = any;
const dictionary: _.Dictionary<SampleObject> | null | undefined = any;
const orders: boolean|string|Array<boolean|string> = any;
{
let iteratees: (value: string) => any|((value: string) => any)[] = (value) => 1;
@@ -6883,7 +6942,7 @@ namespace TestorderBy {
}
{
let iteratees: (value: SampleObject) => any|string|{a: number}|((value: SampleObject) => any|string|{a: number})[] = (value) => 1;
const iteratees: ((value: SampleObject) => _.NotVoid)|string|_.PartialDeep<SampleObject>|Array<((value: SampleObject) => _.NotVoid)|string|_.PartialDeep<SampleObject>> = any;
let result: SampleObject[];
result = _.orderBy(array, iteratees);
@@ -6908,7 +6967,7 @@ namespace TestorderBy {
}
{
let iteratees: (value: SampleObject) => any|string|{a: number}|((value: SampleObject) => any|string|{a: number})[] = (value) => "";
const iteratees: ((value: SampleObject) => _.NotVoid)|string|_.PartialDeep<SampleObject>|Array<((value: SampleObject) => _.NotVoid)|string|_.PartialDeep<SampleObject>> = any;
let result: _.LoDashImplicitArrayWrapper<SampleObject>;
result = _(array).orderBy(iteratees);
@@ -6931,7 +6990,7 @@ namespace TestorderBy {
}
{
let iteratees: (value: SampleObject) => any|string|{a: number}|((value: SampleObject) => any|string|{a: number})[] = (value) => "";
const iteratees: ((value: SampleObject) => _.NotVoid)|string|_.PartialDeep<SampleObject>|Array<((value: SampleObject) => _.NotVoid)|string|_.PartialDeep<SampleObject>> = any;
let result: _.LoDashExplicitArrayWrapper<SampleObject>;
result = _(array).chain().orderBy(iteratees);
@@ -13278,8 +13337,8 @@ namespace TestIdentity {
}
{
let input: {} | null | undefined = any;
_.identity(input); // $ExpectType {} | null | undefined
let input: { a: number; } | null | undefined = any;
_.identity(input); // $ExpectType { a: number; } | null | undefined
_.identity(); // $ExpectType undefined
}
}