import { Type } from "typebox"; import { Check } from "typebox/value"; const RecordSchema = Type.Object({}, { additionalProperties: true }); const StringSchema = Type.String(); const NumberSchema = Type.Number(); const BooleanSchema = Type.Boolean(); const FunctionSchema = Type.Function([], Type.Unknown()); export function isRecordValue( value: T | Contract, ): value is (T | Contract) & Contract { return Check(RecordSchema, value); } export function isStringValue(value: T): value is T & string { return Check(StringSchema, value); } export function isNumberValue(value: T): value is T & number { return Check(NumberSchema, value); } export function isBooleanValue(value: T): value is T & boolean { return Check(BooleanSchema, value); } export function isFunctionValue(value: T): value is T & ((...args: never[]) => void) { return Check(FunctionSchema, value); }