2 ms·
What about addItemsToCart(items) Vs Type ItemCode: string; Type ItemDetails = {...}; addItemsToCart(items:ItemCode[]) or, for a slightl
by esperent 4y ago
What about
addItemsToCart(items)
Vs
Type ItemCode: string;
Type ItemDetails = {...};
addItemsToCart(items:ItemCode[])
or, for a slightly different implementation:
addItemsToCart(items:Record<ItemCode, ItemDetails>)
If you only use trivial examples, types seem silly. But in real examples they become more useful. In this case looking at the function signature give you immediate information about the implementation that is missing from the untyped version.
EDIT: please excuse formatting, I'm on mobile and cannot get it to add spaces before the last code block