Basic usage of this tool is to safely type values received from the outside world, such as through API communication.
import type { Task } from 'path/to/your-declare' import { assertIsTask } from 'path/to/type-predicates' // generated function fetch("path/to/api/task").then(async (data) => { - const json: Task = await data.json() // non-type-safe + const json = await data.json() + assertIsTask(json) // Check with generated function and throw an exception if the data is not valid json /* :Task */ })