the code is look like this:
const num1: number[] = [12, 14, 18, 22, 24];
const findNum: number | undefined = num1.find(elem => elem === 12);
console.log(findNum);
and the error I’m facing is:
1.ts:2:42 - error TS2550: Property 'find' does not exist on type 'number[]'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2015' or later.
2 const findNum: number | undefined = num1.find(elem => elem === 12);
~~~~
Found 1 error in 1.ts:2
the tsconfig:
{
"compilerOptions": {
"target": "es2016",
"lib": ["es2015"],
"module": "commonjs",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true
}
}
I’m using typescript version 5.5.4 and I tried it in the online typescript playground there it’s working without error.
but in my mutcin, it’s not working I tried uninstall typescript and after install but it’s still not working.