@qntm-code/utils
Version:
A collection of useful utility functions with associated TypeScript types. All functions have been unit tested.
13 lines (12 loc) • 525 B
TypeScript
declare namespace Empty {
type String = '';
type Object = Record<string, never>;
type Array = never[];
}
type Empty = Empty.Array | Empty.Object | Empty.String;
type EmptyResult<T> = T extends string ? Empty.String : T extends any[] ? Empty.Array : T extends object ? Empty.Object : never;
/**
* Checks if a given value is empty
*/
export declare function isEmpty<T extends string | any[] | object | null | undefined>(value: T | Empty | null | undefined): value is EmptyResult<T> | null | undefined;
export {};