interface IMember {
name: string;
age: number;
}
// Create reusable assertion guard
const assertMember: AssertionGuard<IMember> = typia.createAssertGuard<IMember>();
// Usage - input will be automatically cast to IMember if validation passes
const unknownData: unknown = { name: "John", age: 25 };
assertMember(unknownData);
// After this line, unknownData is automatically treated as IMember type
console.log(unknownData.name); // TypeScript knows this is safe
Type definition for assertion guard functions in
typia.An assertion guard is a function that asserts an input value's type at runtime and performs a TypeScript type assertion if validation passes. Unlike regular assertion functions that return the validated value, assertion guards return nothing but automatically cast the input parameter to the expected type
T.This type is used by
typia.createAssertGuard<T>()andtypia.createAssertGuardEquals<T>()to generate reusable assertion guard functions.