Typemart project bug - Typescript

In task 5, I did this and got an error in the terminal after running tsc.

if (product.preOrder) {
  console.log("We'll notify you when your item has been dispatched")

It says ‘Object is possibly undefined’ but I am absolutely sure everything is correct, and even looks identical to the walkthrough instructor’s code and his was fine. Bug or no?

1 Like

I realised right before finishing it that I was using .find(), which could potentially return ‘undefined’ if no element is found. I replaced it for .filter() and worked fine.

1 Like