TypeScript Developer interview question · Most asked

What are intersection types and how do they differ from interface extension?

Create a free account to save this page, take notes and track your progress. Sign in

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 & B must satisfy both
  • Conflicts may produce never silently
  • extends errors on conflicts
  • Interfaces often faster to check

More most-asked TypeScript Developer questions

← All TypeScript Developer questions

Was this page helpful?