Skip to content

Typing Pizza App part 9

von Schappler edited this page Nov 27, 2024 · 1 revision

Adding automatic ids to menu items

So far in our code, the ids for new menu items need to be passed manually. We are now going to work into refactoring our code, so when we add a new pizza we can pass to our addPizza function a partial pizza object with no id and let our code to generate that automacically for us.

This change can be easly done if we use the same concecpt / idea we used when creating the order ids.

Important things to notice:

  • After making the changes on the code, new TypeScript warnings may appear:
    • Some of those warnings can be fixed already by placing some variable declarations in the correct position inside the code
    • Other warning will be fixed later with some new concepts yet to be covered in future lectures

Clone this wiki locally