mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-06-28 22:30:01 +00:00
Merge pull request #33228 from OliverJAsh/oja/lodash-is-object-type-guard
Lodash: `isObject`: user-defined type guard
This commit is contained in:
4
types/lodash/common/lang.d.ts
vendored
4
types/lodash/common/lang.d.ts
vendored
@@ -1224,14 +1224,14 @@ declare module "../index" {
|
||||
* @param value The value to check.
|
||||
* @return Returns true if value is an object, else false.
|
||||
*/
|
||||
isObject(value?: any): boolean;
|
||||
isObject(value?: any): value is object;
|
||||
}
|
||||
|
||||
interface LoDashImplicitWrapper<TValue> {
|
||||
/**
|
||||
* see _.isObject
|
||||
*/
|
||||
isObject(): boolean;
|
||||
isObject(): this is LoDashImplicitWrapper<object>;
|
||||
}
|
||||
|
||||
interface LoDashExplicitWrapper<TValue> {
|
||||
|
||||
2
types/lodash/fp.d.ts
vendored
2
types/lodash/fp.d.ts
vendored
@@ -1984,7 +1984,7 @@ declare namespace _ {
|
||||
type LodashIsNil = (value: any) => value is null | undefined;
|
||||
type LodashIsNull = (value: any) => value is null;
|
||||
type LodashIsNumber = (value: any) => value is number;
|
||||
type LodashIsObject = (value: any) => boolean;
|
||||
type LodashIsObject = (value: any) => value is object;
|
||||
type LodashIsObjectLike = (value: any) => boolean;
|
||||
type LodashIsPlainObject = (value: any) => boolean;
|
||||
type LodashIsRegExp = (value: any) => value is RegExp;
|
||||
|
||||
@@ -4291,6 +4291,12 @@ fp.now(); // $ExpectType number
|
||||
_(42).isObject(); // $ExpectType boolean
|
||||
_.chain([]).isObject(); // $ExpectType LoDashExplicitWrapper<boolean>
|
||||
fp.isObject(anything); // $ExpectType boolean
|
||||
if (fp.isObject(anything)) {
|
||||
anything; // $ExpectType object
|
||||
}
|
||||
if (_.isObject(anything)) {
|
||||
anything; // $ExpectType object
|
||||
}
|
||||
}
|
||||
|
||||
// _.isObjectLike
|
||||
|
||||
Reference in New Issue
Block a user