mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-21 08:33:26 +08:00
lodash: signatures of the method _.includes have been changed
This commit is contained in:
@@ -2397,35 +2397,51 @@ module TestCollect {
|
||||
}
|
||||
}
|
||||
|
||||
result = <boolean>_.contains([1, 2, 3], 1);
|
||||
result = <boolean>_.contains([1, 2, 3], 1, 2);
|
||||
result = <boolean>_.contains({ 'moe': 30, 'larry': 40, 'curly': 67 }, 40);
|
||||
result = <boolean>_.contains('curly', 'ur');
|
||||
// _.contains
|
||||
module TestContains {
|
||||
type SampleType = {a: string; b: number; c: boolean;};
|
||||
|
||||
result = <boolean>_([1, 2, 3]).contains(1);
|
||||
result = <boolean>_([1, 2, 3]).contains(1, 2);
|
||||
result = <boolean>_({ 'moe': 30, 'larry': 40, 'curly': 67 }).contains(40);
|
||||
result = <boolean>_('curly').contains('ur');
|
||||
let array: SampleType[];
|
||||
let list: _.List<SampleType>;
|
||||
let dictionary: _.Dictionary<SampleType>;
|
||||
|
||||
result = <boolean>_.include([1, 2, 3], 1);
|
||||
result = <boolean>_.include([1, 2, 3], 1, 2);
|
||||
result = <boolean>_.include({ 'moe': 30, 'larry': 40, 'curly': 67 }, 40);
|
||||
result = <boolean>_.include('curly', 'ur');
|
||||
let target: SampleType;
|
||||
|
||||
result = <boolean>_([1, 2, 3]).include(1);
|
||||
result = <boolean>_([1, 2, 3]).include(1, 2);
|
||||
result = <boolean>_({ 'moe': 30, 'larry': 40, 'curly': 67 }).include(40);
|
||||
result = <boolean>_('curly').include('ur');
|
||||
{
|
||||
let result: boolean;
|
||||
|
||||
result = <boolean>_.includes([1, 2, 3], 1);
|
||||
result = <boolean>_.includes([1, 2, 3], 1, 2);
|
||||
result = <boolean>_.includes({ 'moe': 30, 'larry': 40, 'curly': 67 }, 40);
|
||||
result = <boolean>_.includes('curly', 'ur');
|
||||
result = _.contains<SampleType>(array, target);
|
||||
result = _.contains<SampleType>(array, target, 42);
|
||||
|
||||
result = <boolean>_([1, 2, 3]).includes(1);
|
||||
result = <boolean>_([1, 2, 3]).includes(1, 2);
|
||||
result = <boolean>_({ 'moe': 30, 'larry': 40, 'curly': 67 }).includes(40);
|
||||
result = <boolean>_('curly').includes('ur');
|
||||
result = _.contains<SampleType>(list, target);
|
||||
result = _.contains<SampleType>(list, target, 42);
|
||||
|
||||
result = _.contains<SampleType>(dictionary, target);
|
||||
result = _.contains<SampleType>(dictionary, target, 42);
|
||||
|
||||
result = _(array).contains(target);
|
||||
result = _(array).contains(target, 42);
|
||||
|
||||
result = _(list).contains<SampleType>(target);
|
||||
result = _(list).contains<SampleType>(target, 42);
|
||||
|
||||
result = _(dictionary).contains<SampleType>(target);
|
||||
result = _(dictionary).contains<SampleType>(target, 42);
|
||||
}
|
||||
|
||||
{
|
||||
let result: _.LoDashExplicitWrapper<boolean>;
|
||||
|
||||
result = _(array).chain().contains(target);
|
||||
result = _(array).chain().contains(target, 42);
|
||||
|
||||
result = _(list).chain().contains<SampleType>(target);
|
||||
result = _(list).chain().contains<SampleType>(target, 42);
|
||||
|
||||
result = _(dictionary).chain().contains<SampleType>(target);
|
||||
result = _(dictionary).chain().contains<SampleType>(target, 42);
|
||||
}
|
||||
}
|
||||
|
||||
result = <_.Dictionary<number>>_.countBy([4.3, 6.1, 6.4], function (num) { return Math.floor(num); });
|
||||
result = <_.Dictionary<number>>_.countBy([4.3, 6.1, 6.4], function (num) { return this.floor(num); }, Math);
|
||||
@@ -3034,6 +3050,98 @@ result = <_.Dictionary<number[]>>_({ prop1: 4.2, prop2: 6.1, prop3: 6.4}).groupB
|
||||
result = <_.Dictionary<number[]>>_({ prop1: 4.2, prop2: 6.1, prop3: 6.4}).groupBy<number>(function (num) { return this.floor(num); }, Math).value();
|
||||
result = <_.Dictionary<string[]>>_({ prop1: 'one', prop2: 'two', prop3: 'three'}).groupBy<string>('length').value();
|
||||
|
||||
// _.include
|
||||
module TestInclude {
|
||||
type SampleType = {a: string; b: number; c: boolean;};
|
||||
|
||||
let array: SampleType[];
|
||||
let list: _.List<SampleType>;
|
||||
let dictionary: _.Dictionary<SampleType>;
|
||||
|
||||
let target: SampleType;
|
||||
|
||||
{
|
||||
let result: boolean;
|
||||
|
||||
result = _.include<SampleType>(array, target);
|
||||
result = _.include<SampleType>(array, target, 42);
|
||||
|
||||
result = _.include<SampleType>(list, target);
|
||||
result = _.include<SampleType>(list, target, 42);
|
||||
|
||||
result = _.include<SampleType>(dictionary, target);
|
||||
result = _.include<SampleType>(dictionary, target, 42);
|
||||
|
||||
result = _(array).include(target);
|
||||
result = _(array).include(target, 42);
|
||||
|
||||
result = _(list).include<SampleType>(target);
|
||||
result = _(list).include<SampleType>(target, 42);
|
||||
|
||||
result = _(dictionary).include<SampleType>(target);
|
||||
result = _(dictionary).include<SampleType>(target, 42);
|
||||
}
|
||||
|
||||
{
|
||||
let result: _.LoDashExplicitWrapper<boolean>;
|
||||
|
||||
result = _(array).chain().include(target);
|
||||
result = _(array).chain().include(target, 42);
|
||||
|
||||
result = _(list).chain().include<SampleType>(target);
|
||||
result = _(list).chain().include<SampleType>(target, 42);
|
||||
|
||||
result = _(dictionary).chain().include<SampleType>(target);
|
||||
result = _(dictionary).chain().include<SampleType>(target, 42);
|
||||
}
|
||||
}
|
||||
|
||||
// _.includes
|
||||
module TestIncludes {
|
||||
type SampleType = {a: string; b: number; c: boolean;};
|
||||
|
||||
let array: SampleType[];
|
||||
let list: _.List<SampleType>;
|
||||
let dictionary: _.Dictionary<SampleType>;
|
||||
|
||||
let target: SampleType;
|
||||
|
||||
{
|
||||
let result: boolean;
|
||||
|
||||
result = _.includes<SampleType>(array, target);
|
||||
result = _.includes<SampleType>(array, target, 42);
|
||||
|
||||
result = _.includes<SampleType>(list, target);
|
||||
result = _.includes<SampleType>(list, target, 42);
|
||||
|
||||
result = _.includes<SampleType>(dictionary, target);
|
||||
result = _.includes<SampleType>(dictionary, target, 42);
|
||||
|
||||
result = _(array).includes(target);
|
||||
result = _(array).includes(target, 42);
|
||||
|
||||
result = _(list).includes<SampleType>(target);
|
||||
result = _(list).includes<SampleType>(target, 42);
|
||||
|
||||
result = _(dictionary).includes<SampleType>(target);
|
||||
result = _(dictionary).includes<SampleType>(target, 42);
|
||||
}
|
||||
|
||||
{
|
||||
let result: _.LoDashExplicitWrapper<boolean>;
|
||||
|
||||
result = _(array).chain().includes(target);
|
||||
result = _(array).chain().includes(target, 42);
|
||||
|
||||
result = _(list).chain().includes<SampleType>(target);
|
||||
result = _(list).chain().includes<SampleType>(target, 42);
|
||||
|
||||
result = _(dictionary).chain().includes<SampleType>(target);
|
||||
result = _(dictionary).chain().includes<SampleType>(target, 42);
|
||||
}
|
||||
}
|
||||
|
||||
result = <_.Dictionary<IKey>>_.indexBy(keys, 'dir');
|
||||
result = <_.Dictionary<IKey>>_.indexBy(keys, function (key) { return String.fromCharCode(key.code); });
|
||||
result = <_.Dictionary<IKey>>_.indexBy(keys, function (key) { this.fromCharCode(key.code); }, String);
|
||||
|
||||
360
lodash/lodash.d.ts
vendored
360
lodash/lodash.d.ts
vendored
@@ -3772,160 +3772,82 @@ declare module _ {
|
||||
//_.contains
|
||||
interface LoDashStatic {
|
||||
/**
|
||||
* Checks if a given value is present in a collection using strict equality for comparisons,
|
||||
* i.e. ===. If fromIndex is negative, it is used as the offset from the end of the collection.
|
||||
* @param collection The collection to iterate over.
|
||||
* @param target The value to check for.
|
||||
* @param fromIndex The index to search from.
|
||||
* @return True if the target element is found, else false.
|
||||
**/
|
||||
* @see _.includes
|
||||
*/
|
||||
contains<T>(
|
||||
collection: Array<T>,
|
||||
collection: List<T>|Dictionary<T>,
|
||||
target: T,
|
||||
fromIndex?: number): boolean;
|
||||
fromIndex?: number
|
||||
): boolean;
|
||||
|
||||
/**
|
||||
* @see _.contains
|
||||
**/
|
||||
contains<T>(
|
||||
collection: List<T>,
|
||||
target: T,
|
||||
fromIndex?: number): boolean;
|
||||
|
||||
/**
|
||||
* @see _.contains
|
||||
* @param dictionary The dictionary to iterate over.
|
||||
* @param value The value in the dictionary to search for.
|
||||
**/
|
||||
contains<T>(
|
||||
dictionary: Dictionary<T>,
|
||||
value: T,
|
||||
fromIndex?: number): boolean;
|
||||
|
||||
/**
|
||||
* @see _.contains
|
||||
* @param searchString the string to search
|
||||
* @param targetString the string to search for
|
||||
**/
|
||||
* @see _.includes
|
||||
*/
|
||||
contains(
|
||||
searchString: string,
|
||||
targetString: string,
|
||||
fromIndex?: number): boolean;
|
||||
|
||||
/**
|
||||
* @see _.contains
|
||||
**/
|
||||
include<T>(
|
||||
collection: Array<T>,
|
||||
target: T,
|
||||
fromIndex?: number): boolean;
|
||||
|
||||
/**
|
||||
* @see _.contains
|
||||
**/
|
||||
include<T>(
|
||||
collection: List<T>,
|
||||
target: T,
|
||||
fromIndex?: number): boolean;
|
||||
|
||||
/**
|
||||
* @see _.contains
|
||||
**/
|
||||
include<T>(
|
||||
dictionary: Dictionary<T>,
|
||||
value: T,
|
||||
fromIndex?: number): boolean;
|
||||
|
||||
/**
|
||||
* @see _.contains
|
||||
**/
|
||||
include(
|
||||
searchString: string,
|
||||
targetString: string,
|
||||
fromIndex?: number): boolean;
|
||||
|
||||
/**
|
||||
* @see _.contains
|
||||
**/
|
||||
includes<T>(
|
||||
collection: Array<T>,
|
||||
target: T,
|
||||
fromIndex?: number): boolean;
|
||||
|
||||
/**
|
||||
* @see _.contains
|
||||
**/
|
||||
includes<T>(
|
||||
collection: List<T>,
|
||||
target: T,
|
||||
fromIndex?: number): boolean;
|
||||
|
||||
/**
|
||||
* @see _.contains
|
||||
**/
|
||||
includes<T>(
|
||||
dictionary: Dictionary<T>,
|
||||
value: T,
|
||||
fromIndex?: number): boolean;
|
||||
|
||||
/**
|
||||
* @see _.contains
|
||||
**/
|
||||
includes(
|
||||
searchString: string,
|
||||
targetString: string,
|
||||
fromIndex?: number): boolean;
|
||||
collection: string,
|
||||
target: string,
|
||||
fromIndex?: number
|
||||
): boolean;
|
||||
}
|
||||
|
||||
interface LoDashImplicitArrayWrapper<T> {
|
||||
/**
|
||||
* @see _.contains
|
||||
**/
|
||||
contains(target: T, fromIndex?: number): boolean;
|
||||
|
||||
/**
|
||||
* @see _.contains
|
||||
**/
|
||||
include(target: T, fromIndex?: number): boolean;
|
||||
|
||||
/**
|
||||
* @see _.contains
|
||||
**/
|
||||
includes(target: T, fromIndex?: number): boolean;
|
||||
* @see _.includes
|
||||
*/
|
||||
contains(
|
||||
target: T,
|
||||
fromIndex?: number
|
||||
): boolean;
|
||||
}
|
||||
|
||||
interface LoDashImplicitObjectWrapper<T> {
|
||||
/**
|
||||
* @see _.contains
|
||||
**/
|
||||
contains<TValue>(target: TValue, fromIndex?: number): boolean;
|
||||
|
||||
/**
|
||||
* @see _.contains
|
||||
**/
|
||||
include<TValue>(target: TValue, fromIndex?: number): boolean;
|
||||
|
||||
/**
|
||||
* @see _.contains
|
||||
**/
|
||||
includes<TValue>(target: TValue, fromIndex?: number): boolean;
|
||||
* @see _.includes
|
||||
*/
|
||||
contains<TValue>(
|
||||
target: TValue,
|
||||
fromIndex?: number
|
||||
): boolean;
|
||||
}
|
||||
|
||||
interface LoDashImplicitStringWrapper {
|
||||
interface LoDashImplicitWrapper<T> {
|
||||
/**
|
||||
* @see _.contains
|
||||
**/
|
||||
contains(target: string, fromIndex?: number): boolean;
|
||||
* @see _.includes
|
||||
*/
|
||||
contains(
|
||||
target: string,
|
||||
fromIndex?: number
|
||||
): boolean;
|
||||
}
|
||||
|
||||
interface LoDashExplicitArrayWrapper<T> {
|
||||
/**
|
||||
* @see _.contains
|
||||
**/
|
||||
include(target: string, fromIndex?: number): boolean;
|
||||
* @see _.includes
|
||||
*/
|
||||
contains(
|
||||
target: T,
|
||||
fromIndex?: number
|
||||
): LoDashExplicitWrapper<boolean>;
|
||||
}
|
||||
|
||||
interface LoDashExplicitObjectWrapper<T> {
|
||||
/**
|
||||
* @see _.contains
|
||||
**/
|
||||
includes(target: string, fromIndex?: number): boolean;
|
||||
* @see _.includes
|
||||
*/
|
||||
contains<TValue>(
|
||||
target: TValue,
|
||||
fromIndex?: number
|
||||
): LoDashExplicitWrapper<boolean>;
|
||||
}
|
||||
|
||||
interface LoDashExplicitWrapper<T> {
|
||||
/**
|
||||
* @see _.includes
|
||||
*/
|
||||
contains(
|
||||
target: string,
|
||||
fromIndex?: number
|
||||
): LoDashExplicitWrapper<boolean>;
|
||||
}
|
||||
|
||||
//_.countBy
|
||||
@@ -5357,6 +5279,176 @@ declare module _ {
|
||||
whereValue: W): _.LoDashImplicitObjectWrapper<_.Dictionary<TValue[]>>;
|
||||
}
|
||||
|
||||
//_.include
|
||||
interface LoDashStatic {
|
||||
/**
|
||||
* @see _.includes
|
||||
*/
|
||||
include<T>(
|
||||
collection: List<T>|Dictionary<T>,
|
||||
target: T,
|
||||
fromIndex?: number
|
||||
): boolean;
|
||||
|
||||
/**
|
||||
* @see _.includes
|
||||
*/
|
||||
include(
|
||||
collection: string,
|
||||
target: string,
|
||||
fromIndex?: number
|
||||
): boolean;
|
||||
}
|
||||
|
||||
interface LoDashImplicitArrayWrapper<T> {
|
||||
/**
|
||||
* @see _.includes
|
||||
*/
|
||||
include(
|
||||
target: T,
|
||||
fromIndex?: number
|
||||
): boolean;
|
||||
}
|
||||
|
||||
interface LoDashImplicitObjectWrapper<T> {
|
||||
/**
|
||||
* @see _.includes
|
||||
*/
|
||||
include<TValue>(
|
||||
target: TValue,
|
||||
fromIndex?: number
|
||||
): boolean;
|
||||
}
|
||||
|
||||
interface LoDashImplicitWrapper<T> {
|
||||
/**
|
||||
* @see _.includes
|
||||
*/
|
||||
include(
|
||||
target: string,
|
||||
fromIndex?: number
|
||||
): boolean;
|
||||
}
|
||||
|
||||
interface LoDashExplicitArrayWrapper<T> {
|
||||
/**
|
||||
* @see _.includes
|
||||
*/
|
||||
include(
|
||||
target: T,
|
||||
fromIndex?: number
|
||||
): LoDashExplicitWrapper<boolean>;
|
||||
}
|
||||
|
||||
interface LoDashExplicitObjectWrapper<T> {
|
||||
/**
|
||||
* @see _.includes
|
||||
*/
|
||||
include<TValue>(
|
||||
target: TValue,
|
||||
fromIndex?: number
|
||||
): LoDashExplicitWrapper<boolean>;
|
||||
}
|
||||
|
||||
interface LoDashExplicitWrapper<T> {
|
||||
/**
|
||||
* @see _.includes
|
||||
*/
|
||||
include(
|
||||
target: string,
|
||||
fromIndex?: number
|
||||
): LoDashExplicitWrapper<boolean>;
|
||||
}
|
||||
|
||||
//_.includes
|
||||
interface LoDashStatic {
|
||||
/**
|
||||
* Checks if target is in collection using SameValueZero for equality comparisons. If fromIndex is negative,
|
||||
* it’s used as the offset from the end of collection.
|
||||
*
|
||||
* @alias _.contains, _.include
|
||||
*
|
||||
* @param collection The collection to search.
|
||||
* @param target The value to search for.
|
||||
* @param fromIndex The index to search from.
|
||||
* @return True if the target element is found, else false.
|
||||
*/
|
||||
includes<T>(
|
||||
collection: List<T>|Dictionary<T>,
|
||||
target: T,
|
||||
fromIndex?: number
|
||||
): boolean;
|
||||
|
||||
/**
|
||||
* @see _.includes
|
||||
*/
|
||||
includes(
|
||||
collection: string,
|
||||
target: string,
|
||||
fromIndex?: number
|
||||
): boolean;
|
||||
}
|
||||
|
||||
interface LoDashImplicitArrayWrapper<T> {
|
||||
/**
|
||||
* @see _.includes
|
||||
*/
|
||||
includes(
|
||||
target: T,
|
||||
fromIndex?: number
|
||||
): boolean;
|
||||
}
|
||||
|
||||
interface LoDashImplicitObjectWrapper<T> {
|
||||
/**
|
||||
* @see _.includes
|
||||
*/
|
||||
includes<TValue>(
|
||||
target: TValue,
|
||||
fromIndex?: number
|
||||
): boolean;
|
||||
}
|
||||
|
||||
interface LoDashImplicitWrapper<T> {
|
||||
/**
|
||||
* @see _.includes
|
||||
*/
|
||||
includes(
|
||||
target: string,
|
||||
fromIndex?: number
|
||||
): boolean;
|
||||
}
|
||||
|
||||
interface LoDashExplicitArrayWrapper<T> {
|
||||
/**
|
||||
* @see _.includes
|
||||
*/
|
||||
includes(
|
||||
target: T,
|
||||
fromIndex?: number
|
||||
): LoDashExplicitWrapper<boolean>;
|
||||
}
|
||||
|
||||
interface LoDashExplicitObjectWrapper<T> {
|
||||
/**
|
||||
* @see _.includes
|
||||
*/
|
||||
includes<TValue>(
|
||||
target: TValue,
|
||||
fromIndex?: number
|
||||
): LoDashExplicitWrapper<boolean>;
|
||||
}
|
||||
|
||||
interface LoDashExplicitWrapper<T> {
|
||||
/**
|
||||
* @see _.includes
|
||||
*/
|
||||
includes(
|
||||
target: string,
|
||||
fromIndex?: number
|
||||
): LoDashExplicitWrapper<boolean>;
|
||||
}
|
||||
|
||||
//_.indexBy
|
||||
interface LoDashStatic {
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user