const assert: {
<ValueType>(
value: ValueType,
message?: string,
): asserts value is ValueType extends null | undefined | false | 0 | ""
? never
: ValueType;
type: <T extends TypeValidator<any> | CoerceableToTypeValidator>(
value: any,
type: T,
optionalMessage?: string,
) => asserts value is UnwrapTypeFromCoerceableOrValidator<T>;
};Throws an error if value is not truthy.
@paramvalue — The value to test for truthiness@parammessage — An optional error message to use. If unspecified, "Assertion failed" will be used.
<ValueType>(value: ValueType, message?: string): asserts value is ValueType extends null | undefined | false | 0 | "" ? never : ValueType;Throws an error if its argument isn't the correct type.
@paramvalue — The value to test the type of@paramtype — The type thatvalueshould be, as either aTypeValidator(from thetypes.*namespace) or a value which can be coerced into aTypeValidatorvia thetypes.coercefunction, likeString,Boolean, etc.@parammessage — An optional error message to use. If unspecified, a generic-but-descriptive message will be used.
type: <T extends TypeValidator<any> | CoerceableToTypeValidator>(value: any, type: T, optionalMessage?: string) => asserts value is UnwrapTypeFromCoerceableOrValidator<T>;