Q37. What is excess property checking?

When a fresh object literal is assigned to a target object type, TypeScript performs an additional check for unexpected properties. This helps catch misspelled fields. It is not a general exact-object-type system; assigning a previously stored variable can behave differently if it structurally satisfies the target.

Excess property checks are particularly visible on direct object literals passed to functions or assigned to typed variables.

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 common mistake can excess property checking catch?