I am trying to interface a map loop in JavaScript, what I have done is:
interface RoutesType {
path: string;
name: string;
icon: string;
layout: string;
}
the code of the map loop is:
// creates the links that appear in the left menu / Sidebar
const createLinks = (routes: object[]) => {
return routes.map((prop: RoutesType, key: number) => {
return (
<NavItem key={key}>
<NavLink to={prop.layout + prop.path} tag={NavLinkRRD} onClick={closeCollapse} activeClassName="active">
<i className={prop.icon} />
{prop.name}
</NavLink>
</NavItem>
);
});
};
The error I cannot understand is the following
TypeScript error: Argument of type '(prop: RoutesType, key: number) => Element' is not assignable to parameter of type '(value: object, index: number, array: object[]) => Element'.
Types of parameters 'prop' and 'value' are incompatible.
Type '{}' is missing the following properties from type 'RoutesType': path, name, icon, layout
Could you help me understand this issue? Thanks, F.