Programming Languages
TypeScript
Interview
Oct 01, 2025
What is the difference between type and interface in TypeScript?
Detailed Explanation
Key differences: 1) Declaration merging - interfaces can be merged, types cannot, 2) Extensibility - interfaces use extends, types use intersection (&), 3) Computed properties - types support computed properties, interfaces do not, 4) Union types - types can represent unions, interfaces cannot directly, 5) Primitive types - types can alias primitives, interfaces cannot, 6) Performance - interfaces are generally faster for object types. Use interfaces for object shapes that might be extended, types for unions and computed properties.
Discussion (0)
No comments yet. Be the first to share your thoughts!
Share Your Thoughts