Problem:
I am re-writing my React app with Typescript. I am trying to implement all the components as functional components.
Typescript allows us to make use of Type Aliases and Interfaces to define the shape of an object or a function signature. I have already gone through the difference between Types vs Interfaces.
Most all the articles I went through have defined a component by making use of an interface where type alias could have been used. As far as I know, both interface and type alias gives the same result for a React component, then why almost in every definition interface is used
I tried a few articles on why Interface is being used mostly instead of type alias but could not find anything useful.
What is the best way to annotate React component props, with interface or with type aliases?
Example with Interface:
interface AppProps {
color?: string;
}
const App = (props: AppProps) : JSX.Element => {
return <div>{props.color}</div>
}