小编Joh*_*han的帖子

仅当使用“--downlevelIteration”标志或使用“es2015”或更高版本的“--target”时,才能迭代类型“Set<unknown>”

我试图获取数组中的所有 id,然后使用 React TypeScript 删除重复项。

这是我的代码:

const uniqueMuscle = workoutexercices.map((exercice: any) => {
    let exercicesId = exercice.id;
    exercicesId = [...new Set(exercicesId)];
    return exercicesId;
  });
Run Code Online (Sandbox Code Playgroud)

VSCode[...new Set(exercicesId)];用红色下划线告诉我: Type 'Set<unknown>' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher

所以我去了我的ts.config并更改了值,但仍然是相同的错误。

这是我的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, …
Run Code Online (Sandbox Code Playgroud)

typescript reactjs

34
推荐指数
3
解决办法
4万
查看次数

我应该在生产中手动禁用 React StrictMode 吗?

我正在阅读文档并了解到 React仅StrictMode用于开发,它解释了为什么我们有双重调用。

这很好,但这是否意味着我必须StrictMode为我的生产禁用手动功能,或者反应build命令是否会自行执行此操作?

reactjs react-strictmode

6
推荐指数
1
解决办法
3287
查看次数

标签 统计

reactjs ×2

react-strictmode ×1

typescript ×1