export type FromFn = (input: A) => Promise; /** A safe conversion from type A to type B */ export type From = { /** * Convert `input` safely and asynchronously into an output. */ from: FromFn; }; /** The output of a conversion type or function */ export type OutputOf< F extends From | FromFn > = F extends From ? Output : F extends FromFn ? Output : never; /** The input of a conversion type or function */ export type InputOf< F extends From | FromFn > = F extends From ? Input : F extends FromFn ? Input : never; /** * A type "conversion" from any type to itself */ export function identity(): From { return { async from(a) { return a; }, }; }