API reference › @evolu/common › Types › Refinement
type Refinement<A, B> = (a: A) => a is B;
Defined in: packages/common/src/Types.ts:91
A type guard function that refines type A to a narrower type B.
Example
type Animal = { name: string };
type Dog = Animal & { breed: string };
const isDog: Refinement<Animal, Dog> = (animal): animal is Dog =>
"breed" in animal;
const animal: Animal = { name: "Dog", breed: "Beagle" };
if (isDog(animal)) {
console.log(animal.breed); // Safe access to `breed`
}