QuizNot attempted
Generic List infers T from items
1–4 to choose, Enter to submit
Show answer & explanation
Correct answer:
{ id: number; first: string }
- JSX props are inferred like function arguments:
itemsgives `T = { id: number - first: string }
andonClick's parameter is then contextually typed fromT`, so a single generic component serves strings, numbers and objects. - Not unknown: that is only what you get when nothing constrains
T. - Not any: generics keep the type.
- Not the literal type: object literal properties are widened (
1tonumber) unless you useas const.