代码之家  ›  专栏  ›  技术社区  ›  punkish

tsc不会忽略node_modules文件

  •  0
  • punkish  · 技术社区  · 2 年前

    我的编译器选项包括:

    {
        "compilerOptions": {
          "outDir": "./dist",
          "allowJs": true,
          "target": "es6",
          "esModuleInterop": true,
          "skipLibCheck": true,
          "types": []
        },
        "include": ["src/**/*"],
        "exclude": ["node_modules"]
      }
    

    然而, tsc 抱怨中的文件类型错误 node_modules 文件夹,以及:

    src/index.ts:125:21 - error TS2802: Type 'IterableIterator<number>' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher.
    

    即使我的目标设定为 es6 .

    我做错了什么?

    1 回复  |  直到 2 年前
        1
  •  2
  •   Evert    2 年前

    如果你跑步 tsc [filename] , tsconfig.json 将被忽略。要解决问题,只需运行 tsc 本身。

    推荐文章