TypeScript Developer interview question · Most asked
What are intersection types and how do they differ from interface extension?
Summary
Intersection types (A & B) combine types so the value must satisfy all of them. Interface extends also combines but reports conflicts eagerly, whereas conflicting intersection members can silently become never.
Longer Answer
Intersections are useful for mixins, adding props (T & { id: string }) and branding. Interfaces with extends usually give better error messages and compiler performance for large object hierarchies.
Key Points
A & Bmust satisfy both- Conflicts may produce
neversilently extendserrors on conflicts- Interfaces often faster to check
More most-asked TypeScript Developer questions
- Explain `any`, `unknown` and `never`.
- What are the differences between `interface` and `type` aliases?
- What is structural typing in TypeScript?
- What is type narrowing and what techniques does TypeScript support?
- What are discriminated unions and why are they powerful?
- What are generics and how do constraints work?
- Which built-in utility types do you use most, and what do they do?
- What is TypeScript and what problems does it solve?