succulent
Version:
Powerful and easy runtime type checking
15 lines (14 loc) • 519 B
TypeScript
import { SchemaBase } from "../schema.js";
/**
* When catching errors, you can use something like `error instanceof CheckError` to determine if
* the error is from a failed call to `check`.
*/
export declare class CheckError extends TypeError {
}
/**
* @param x The value to check
* @param schema The schema to check against
* @throws {TypeError} when the provided value does not match the schema
*/
export declare function check<T>(x: unknown, schema: SchemaBase<T>): asserts x is T;
export { check as guard };