type-fns
Version:
A set of types, type checks, and type guards for simpler, safer, and easier to read code.
26 lines (25 loc) • 577 B
TypeScript
/**
* narrows the type to remove undefined
*
* ref
* - https://stackoverflow.com/a/63045455/3068233
*/
export type IsDefined<T> = T extends undefined ? never : T;
/**
* narrows the type to remove undefined
*
* note
* - alias of IsDefined
*/
export type NotUndefined<T> = IsDefined<T>;
/**
* checks whether the value is not undefined
*/
export declare const isDefined: <T>(val: T) => val is IsDefined<T>;
/**
* checks whether the value is not undefined
*
* note
* - alias of isDefined
*/
export declare const isNotUndefined: <T>(val: T) => val is IsDefined<T>;