Q16. What is a default generic type parameter?

A generic default supplies a fallback type argument when the caller does not provide one and inference does not select another. Defaults reduce boilerplate, but should not conceal uncertainty or make the API harder to understand.

In type Box<T = string> = { value: T }, Box uses string unless another T is specified.

Note

Interview approach: define the concept, explain why it matters, then mention one trade-off or limitation.

TypeScript concept
// Illustrative TypeScript contract
type Identifier = string;
const id: Identifier = "item-1";
💡 The example demonstrates the compile-time contract discussed in this question.
Key Takeaways
  • Explain the concept in your own words.
  • Know the practical trade-off and its limits.
  • Use a small example to demonstrate the idea.
Knowledge Check

What is the default T in `type Box<T = string>` when no type argument is supplied?