import type { Infer } from "superstruct"; import { currentUser, redeemedPledge, sessionInfo } from "./structs.js"; // Generic type helpers type Brand = { __brand: B }; export type Branded = T & Brand; /** * Make properties in union K required in T. * * @example * ```ts * interface User { * id: string; * name?: string; * email?: string; * } * * type UserWithRequiredName = RequiredPick; * // Result: { id: string; name: string; email?: string; } * ``` */ export type RequiredPick = T & Required>; /** * A branded string. * * Use this type to make a HTML string as trusted. This can be either HTML * coming from a source that we know is safe (statically generated markdown * that exists in our codebase) or sanitized user-generated content. */ export type TrustedHtml = Branded; // Common ITC types export type CurrentUser = Infer>; export type SessionInfo = Infer>; export type RedeemedPledge = Infer>; export type FailurePayload = | { type: "API_ERROR"; code: number; } | { type: "NETWORK_ERROR" | "UNKNOWN_ERROR" | "VALIDATION_ERROR"; };