Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumTypeScriptgeneric constraintsSingle-choice MCQ

A function is constrained with `T extends { id: number }`. What happens to the extra `name` property when you pass an object that has both `id` and `name`?

function withId<T extends { id: number }>(x: T): T { return x; } const r = withId({ id: 1, name: "Ada" }); const nm = r.name;