How do you implement a generic function that infers its return type based on its input parameter in TypeScript?
Instruction: Provide an example of a generic function that takes an argument and returns a value of the same type as the argument.
Context: Evaluates the candidate's proficiency with TypeScript generics, especially their understanding of advanced generic patterns like conditional types and type inference within generics.
Updated
Official answer available
Read the opening below, then unlock the full answer and practical guidance.
Thank you for posing such an intriguing question...