What are Higher-Order Components (HOC) in TypeScript, and how do you type them?
Instruction: Provide an example to demonstrate the typing of a Higher-Order Component in TypeScript.
Context: This question assesses the candidate's ability to work with advanced React patterns in TypeScript, specifically with typing Higher-Order Components for reusability and type safety.
Updated
Official answer available
Read the opening below, then unlock the full answer and practical guidance.
A higher-order component is a function that accepts a component and returns another component. If it supplies a prop, the returned component's caller should not be required to provide that injected prop.
This complete React/TypeScript example intentionally supports one small prop contract...