Advanced TypeScript type FTW!