extends keyword do in TypeScript generics?name property of type string?<T extends { name: string }> to ensure the type has a name property of type string.extends instead of just using a specific type?extends constraint?function logName<T extends { name: string }>(obj: T): voidlogName accepts an object obj of any type T as long as T has a name property of type string.T extends U mean in TypeScript generics?T extends U means T must be a subtype or satisfy the structure of U.
length property?Only <T extends { length: number }> ensures the type has a length property.
function f<T extends { name: string }>(obj: T)?TypeScript shows a compile-time error because number does not have a name property.
Generic constraints allow flexibility while keeping type safety.
Option D correctly uses extends in the generic parameter list.
extends help in writing safer TypeScript code.extends to accept only objects with a length property.