foxts
Version:
Opinionated collection of common TypeScript utils by @SukkaW
21 lines (19 loc) • 1.44 kB
TypeScript
declare function not(arg: null): <T>(i: T | null) => i is T;
declare function not(arg: undefined): <T>(i: T | undefined) => i is T;
declare function not(arg: false): <T>(i: T | false) => i is T;
declare function not(arg: 'nullish'): <T>(i: T | null | undefined) => i is T;
declare function not(arg: 'falsy'): <T>(i: T | 0 | '' | false | null | undefined) => i is T;
declare function is(arg: null): (i: unknown) => i is null;
declare function is(arg: undefined): (i: unknown) => i is undefined;
declare function is(arg: false): (i: unknown) => i is false;
declare function is(arg: 'nullish'): (i: unknown) => i is null | undefined;
declare function is(arg: 'falsy'): (i: unknown) => i is 0 | '' | false | null | undefined;
declare function is(arg: 'truthy'): <T>(i: T | 0 | '' | false | null | undefined) => i is T;
declare const isTruthy: <T>(i: T | 0 | "" | false | null | undefined) => i is T;
declare const isFalsy: (i: unknown) => i is 0 | "" | false | null | undefined;
declare const isNonNull: <T>(i: T | null) => i is T;
declare const isNonNullish: <T>(i: T | null | undefined) => i is T;
declare function nullthrow<T>(value: T | null | undefined, message?: string): T;
declare function invariant<T>(value: T | null | undefined, message?: string): asserts value is T;
declare function never(value: never, valueMetaName?: string): never;
export { invariant, is, isFalsy, isNonNull, isNonNullish, isTruthy, never, not, nullthrow };