Equals
Let you test if two types are the same
Type level testing

A less trivial example: The code and it's corresponding test file.
Making sure that a zod schema validates a given type

import { z } from "zod";
import { assert, type Equals } from "tsafe/assert";
import { id } from "tsafe/id";
type Xyz= // ...
const zXyz = (()=>{
type TargetType = Xyz;
const zTargetType = z.;
type InferredType = z.infer<typeof zTargetType>;
assert<Equals<TargetType, InferredType>>;
return id<z.ZodType<TargetType>>(zTargetType);
})();
Making sure all cases of a switch are dealt with

Last updated
Was this helpful?