Typescript Infer Generic Type From Parameter