diff --git a/src/utils/is-empty.ts b/src/utils/is-empty.ts index af897e3..4166454 100644 --- a/src/utils/is-empty.ts +++ b/src/utils/is-empty.ts @@ -8,6 +8,27 @@ import { isNumber } from './is-number'; import { isSet } from './is-set'; import { isObject } from './is-object'; + +interface IEmptyArguments extends IArguments { + length: 0; +} + +interface IEmptyObj { + [s: string]: never; +} + +type IEmptyTypes = ( + null | + undefined | + boolean | + number | + never[] | + '' | + IEmptyArguments | + Set | + IEmptyObj +); + /** * Checks if `o` is an empty object. An object is "empty" if it: * @@ -17,7 +38,7 @@ import { isObject } from './is-object'; * * @returns `true` if `o` is empty */ -export function isEmpty(o: unknown): boolean { +export function isEmpty(o: unknown): o is IEmptyTypes { if (isNull(o) || isUndefined(o) || isBoolean(o) || isNumber(o)) { return true; }