Q31. What does implements do?
implements checks that a class instance is compatible with an interface or object type. It does not generate missing members or create a runtime interface. The class must provide compatible members itself.
Use implements to verify that a concrete class meets a capability contract.
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
Does implements create interface methods?