TypeScript · Junior · Question 6 of 75

What's the difference between interface and type for describing an object?

Explanation

For objects they're almost interchangeable. Differences: interfaces with the same name merge (declaration merging) and are extended with extends. Type aliases describe unions, tuples, primitives, conditional and mapped types. Many teams use interface for objects and type for everything else.

Further reading

Problem with a question

TypeScript · Junior · question 6

Test yourself

Take the TypeScript · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz