Issue
I'm trying to get all ids in Array, and then remove duplicates with React TypeScript.
Here is my code :
const uniqueMuscle = workoutexercices.map((exercice: any) => {
let exercicesId = exercice.id;
exercicesId = [...new Set(exercicesId)];
return exercicesId;
});
VSCode underlines [...new Set(exercicesId)];
in red and tells me :
Type 'Set<unknown>' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher
So I went to my ts.config
and I changed the value, but still the same error.
Here is my ts.config
:
{
"compilerOptions": {
"target": "es2015",
I "downlevelIteration": true
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noFallthroughCasesInSwitch": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx"
},
"include": [
"src"
]
}
Any idea why I keep having this error ?
Solution
had same error, setting tsconfig.json from CommonJS to Es modules with target, module, moduleResolution helped me.
my tsconfig.json:
"compilerOptions": {
"target": "ES2020",
"module": "ESNext",
"moduleResolution": "NodeNext",
"jsx": "react-jsx",
"baseUrl": "./",
"resolveJsonModule": true,
"esModuleInterop": true
}
}
Answered By - Tonikprofik
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.