I have an array:
const commandsBarImitation = [
{location:"before", locateInMenu:"auto", widget:"dxButton", hasList: true, options: {}},
{location:"before", locateInMenu:"auto", widget:"dxButton", hasList: true, options: {}},
{location:"before", locateInMenu:"auto", widget:"dxButton", hasList: true, options: {}},
];
There is also a function that renders a list of components, and takes this array as an argument:
interface IPropsCommandBarTemplates {
isNeedLogoIcon?: boolean;
hasList: boolean;
logoName?: string;
itemText?: string;
}
export const renderToolbarCommandItems = <T, >(itemDataArr: Array<IPropsCommandBarTemplates>) => {
return itemDataArr.map((item, i) => {
return (
<Item
cssClass={'testClass'}
key={i}
locateInMenu={'auto'}
// showText={item.location !== 'after' ? 'always' : 'inMenu'}
// {...item}
// render={item.location !== 'after' ? () =>
// <CommandBarItemTemplates
// itemText={'Добавить'}
// isNeedLogoIcon
// hasList={true}
// logoName={'a-solid fa-ban-bug'}
// /> : undefined}
/>)
})}
but when I call the function, passing an argument of the wrong type, the compiler does not error:
const commandsBarImitation = [
{location:"before", locateInMenu:"auto", widget:"dxButton", hasList: true, options: {}, as: 'lalalend', asdasd: 2},
{location:"before", locateInMenu:"auto", widget:"dxButton", hasList: true, options: {}, tt: 'tt'},
{location:"before", locateInMenu:"auto", widget:"dxButton", hasList: true, options: {}},
];
renderToolbarCommandItems(commandsBarImitation)
Properties as: 'lalalend'
or asdasd: 2
do not exist in the IPropsCommandBarTemplates
interface. So why does the function take an argument with the wrong type and how can this be fixed?