TypeScript types and interfaces
We have seen the basic usage of defining an object in the previous article on TypeScript types. However when we used this object it looked like this:
const getFullName = (user: {firstname: string, lastname: string}): string => {
return `${user.firs...
h.daily-dev-tips.com3 min read
Jorge Romero
I used to be confused about them at first. But as you say, they are basically the same thing.
I tend to use interfaces for classes that will implement them. Usually describing the methods they must implement. And types when I just want a short alias for a JavaScript object.
Thanks for sharing :)