Skip to content

Typing Pizza App part 1

von Schappler edited this page Oct 18, 2024 · 1 revision

Adding basic type definitions to Pizza App

Now that we had a glance on how to add basic type definitions on a TypeScript codebase, it's the time to start adding the basic types on our pizza application.

To do so, let's follow this quick workflow:

  • We expect the orderId to be a number
  • We expect the cashInRegister also to be a number
  • Some other internal functios parameters can benefit from basic types
  • Fix the code so it can work properly after adding those type definitions

And with that the basic type declarations should be added correctly into the Pizza App.


Using basic types types on the Pizza App

After a overview of the code, let's add some basic types to our variables and fix some function calls:

let cashInRegister: number = 100;
let orderId: number = 1;

/* some definitions */

const completeOrder = (orderId: number) => {
  /* function body */
};

/* rest of the code */

completeOrder(1);

Clone this wiki locally