I got unstuck at task3,
I used find() method on products for product, but it made error and it is below.
index.ts:12:26 - error TS2550: Property ‘find’ does not exist on type ‘{ name: string; price: string; preOrder: string; }’. Do you need to change your target library? Try changing the ‘lib’ compiler option to ‘es2015’ or later.
but, when I use filter(), it works. I really don’t know why, and it’s even said to use find() on hint box!
I’ve just started to study Typescript, so many things are new for me.
The difference is that the filter method returns an empty array if no product is found whereas the find method returns ‘undefined’ in that case. So product is a different type when you use find or filter. Until step 3 that should not matter. Have you already written code from the following steps?
Hi, I got the same error message as mentioned when using the .find method AND compiling with passing index.ts as an argument:
$ tsc index.ts.
When calling
$ tsc
without arguments, compilation works without errors.
A possible cause is explained here:
which leads to here:
The given explanation is, that when passing filename(s) to the compiler, the tsconfg.json is ignored and falls back to some default options, supposedly.
When using the compiler target setting from the lesson’s environment (display via $ cat tsconfig.json):
$ tsc index.ts --lib es2017
the error message changes (to error TS2584, missing ‘console’ name), which indicates the previously reported missing .find methid is not an issue any more.