Let's say I have a type defined like this:
type gridProps = {
itemsArrayFiltered: object[],
cardWidth: number,
cardHeight: number
}
And I have a React component like this:
const Grid =
({ itemsArrayFiltered, cardWidth = 280, cardHeight }: gridProps) =>
(whatever)
If I do not provide the cardWidth property in the type gridProps, then I get the error message:
Property 'cardWidth' does not exist on type 'gridProps'.ts(2339)
That is correct but, the question is: Should it not be enough to provide the default value 280? I feel I am duplicating code by providing a number default value and also writing number in the type gridProps. Is there a better way to avoid this?