How I made database joins type-safe in TypeScript.