Rebasely Beta: data may be purged

justintypescript-ultra-strict Public

TypeScript · 29 lines · 862 B · at 8396947

export type Account = { balanceCents: number; frozen: boolean };export type TransferFailure =  | { kind: "invalid_amount" }  | { kind: "same_account" }  | { kind: "unknown_account"; id: string }  | { kind: "frozen"; id: string }  | { kind: "insufficient_funds"; id: string; balanceCents: number; amountCents: number };export class TransferError extends Error {  declare readonly kind: TransferFailure["kind"];  declare readonly id?: string;  declare readonly balanceCents?: number;  declare readonly amountCents?: number;  constructor(failure: TransferFailure) {    super(failure.kind);    Object.assign(this, failure);  }}/** Throws TransferError when the transfer is not allowed. */export function transfer(  accounts: Record<string, Account>,  from: string,  to: string,  amountCents: number,): Record<string, Account> {  // TODO}