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.


I think it’s really not great that the course designer(s) let beginners run into this pitfall by proposing .find in the hint without giving some explanation about the implication.

IMO a guided course should provide th is help, so that I don’t need to grind through it myself. This is worsening the user experience a lot for me.

@codecademy, please consider fixing this.

hey everyone as I am learning typemart. I face an issue in Typemart Project.
I am unable to import the array present in different file.
After writing this line “import products from ‘./products’;” in index.ts file, when I run the file. I got import error.
$ node index.ts
(node:120) Warning: To load an ES module, set “type”: “module” in the package.json or use the .mjs extension.
(Use node --trace-warnings ... to show where the warning was created)
import products from ‘./products’;

SyntaxError: Cannot use import statement outside a module
anyone who can help what’s wrong in this.

In the terminal, run tsc index.ts to compile the index.js file

Then run node index.js

I hope this helps