UNPKG

ts-guards

Version:
33 lines (32 loc) 1.48 kB
/** * Throw Type Error */ export declare function error(expected: any, actual: unknown): never; /** * Primitive Type Asserts */ export declare function isNull(x: unknown): asserts x is null; export declare function isUndefined(x: unknown): asserts x is undefined; export declare function isBoolean(x: unknown): asserts x is boolean; export declare function isString(x: unknown): asserts x is string; export declare function isNumber(x: unknown): asserts x is number; export declare function isBigInt(x: unknown): asserts x is bigint; export declare function isSymbol(x: unknown): asserts x is symbol; export declare function isNotNullOrUndefined<T>(x: T): asserts x is NonNullable<T>; export declare function isObject(x: unknown): asserts x is object; /** * Standard Object Asserts */ export declare function isArray(x: unknown): asserts x is Array<unknown>; export declare function isArrayOf(x: unknown, y: (x: unknown) => boolean): asserts x is Array<unknown>; export declare function isObjectPropertyOf<P extends PropertyKey>(x: unknown, property: P): asserts x is { [K in P]: unknown; }; export declare function areObjectPropertiesOf<P extends PropertyKey>(x: unknown, property: P[]): asserts x is { [K in P]: unknown; }; /** * Literal Type Asserts */ export declare function isLiteral<T>(x: unknown, value: T): asserts x is typeof value; export declare function isLiteralType<T>(x: unknown, set: Set<T>): asserts x is typeof set extends Set<infer T> ? T : never;