examerioLogin
← Fullstack with Vue.jsQuestion 19 of 62

What can type do that interface cannot in TypeScript?

📘 Explanation

type can define unions and intersections, like "loading" | "success", which interface cannot express since interfaces only describe object shapes. Declaration merging is actually a feature of interface, not type, so that option is backwards. Extending classes and annotating function parameters are things both type and interface can handle, so those don't highlight a real difference.

Related questions

← PreviousNo login needed