I want to pass typed data from a database into a generic transformer function. It seems like the best way to accomplish this in Typescript is via a discriminating union. But