Lodash: isObject: user-defined type guard

This commit is contained in:
Oliver Joseph Ash
2019-02-20 12:21:34 +00:00
parent 9e673d252d
commit efbf4f4d1d
2 changed files with 5 additions and 1 deletions
+1 -1
View File
@@ -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;
+4
View File
@@ -4291,6 +4291,10 @@ fp.now(); // $ExpectType number
_(42).isObject(); // $ExpectType boolean
_.chain([]).isObject(); // $ExpectType LoDashExplicitWrapper<boolean>
fp.isObject(anything); // $ExpectType boolean
if (fp.isObject(anything)) {
// $ExpectType object
anything
};
}
// _.isObjectLike