Merge pull request #6774 from chrootsu/lodash-has

lodash: signatures of the method _.has have been changed
This commit is contained in:
Masahiro Wakame
2015-11-17 00:04:00 +09:00
2 changed files with 40 additions and 10 deletions
+28 -8
View File
@@ -6043,14 +6043,34 @@ result = <number>_.get<number>({ 'a': [{ 'b': { 'c': 3 } }] }, 'a[0].b.c');
}
// _.has
result = <boolean>_.has({}, '');
result = <boolean>_.has({}, 42);
result = <boolean>_.has({}, true);
result = <boolean>_.has({}, ['', 42, true]);
result = <boolean>_({}).has('');
result = <boolean>_({}).has(42);
result = <boolean>_({}).has(true);
result = <boolean>_({}).has(['', 42, true]);
module TestHas {
type SampleObject = {a: number; b: string; c: boolean;};
let object: SampleObject;
{
let result: boolean;
result = _.has<SampleObject>(object, '');
result = _.has<SampleObject>(object, 42);
result = _.has<SampleObject>(object, true);
result = _.has<SampleObject>(object, ['', 42, true]);
result = _(object).has('');
result = _(object).has(42);
result = _(object).has(true);
result = _(object).has(['', 42, true]);
}
{
let result: _.LoDashExplicitWrapper<boolean>;
result = _(object).chain().has('');
result = _(object).chain().has(42);
result = _(object).chain().has(true);
result = _(object).chain().has(['', 42, true]);
}
}
// _.invert
{
+12 -2
View File
@@ -10596,14 +10596,24 @@ declare module _ {
* @param path The path to check.
* @return Returns true if path is a direct property, else false.
*/
has(object: any, path: string|number|boolean|Array<string|number|boolean>): boolean;
has<T extends {}>(
object: T,
path: StringRepresentable|StringRepresentable[]
): boolean;
}
interface LoDashImplicitObjectWrapper<T> {
/**
* @see _.has
*/
has(path: string|number|boolean|Array<string|number|boolean>): boolean;
has(path: StringRepresentable|StringRepresentable[]): boolean;
}
interface LoDashExplicitObjectWrapper<T> {
/**
* @see _.has
*/
has(path: StringRepresentable|StringRepresentable[]): LoDashExplicitWrapper<boolean>;
}
//_.invert