typeparse
Version:
Runtime object transformation, parsing and validation with inferred static TypeScript typing.
21 lines (20 loc) • 744 B
TypeScript
export declare type ExpectedType = "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" | "array" | "unknown";
export declare enum TypeParseErrorCode {
NOT_FOUND = "NOT_FOUND",
INVALID_TYPE = "INVALID_TYPE",
UNABLE_TO_PARSE = "UNABLE_TO_PARSE"
}
export interface TypeParseErrorDetails {
expectedType?: ExpectedType;
typeFound?: unknown;
key?: string | string[];
customError?: string;
}
export declare function typeOf(value: unknown): ExpectedType;
export declare class TypeParseError implements Error {
readonly code: TypeParseErrorCode;
readonly name: string;
readonly message: string;
constructor(parameters: TypeParseErrorDetails);
toString(): string;
}