Interview answer guide · 01
Explain TypeScript choices
How do types, interfaces, declaration merging, and callback typing fit into a maintainable front-end codebase?
A clear answer
What I would say in an interview.
I use TypeScript to make component and API contracts explicit. I reach for an interface when I want an object-shaped contract that can be extended or augmented; I use a type alias for unions, intersections, primitives, and computed compositions. Declaration merging is useful for deliberate augmentation of an existing interface, but I avoid relying on it for ordinary domain models because a single visible definition is easier to trace. For callbacks, I declare the arguments and return value at the boundary so consumers know exactly what they may receive and what they are expected to return.
Key points
Details worth backing up.
- 01
Interfaces describe object shapes and can extend other interfaces; type aliases are especially expressive for unions and composed types.
- 02
Same-named interfaces merge. Treat this as a targeted extension mechanism, not a default modeling strategy.
- 03
Use a function type such as `(event: Event) => void` for a callback whose return value is intentionally ignored.
- 04
Do not mark a callback parameter optional unless the caller may actually omit it when invoking the callback.
References