与 downlevelIteration 相关的 Mocha typescript 编译问题

Mocha typescript compilation issue related to downlevelIteration

我刚刚尝试将 Mocha 合并到我的 Typescript 应用程序中。这是我的 tsconfig.json

{
         "compilerOptions": {
             "target": "ES6",
             "module": "commonjs",
             "outDir": "../dist",
             "sourceMap": true,
             "esModuleInterop": true,
             "downlevelIteration": true
         },
         "include": [
             "**/*.ts"
         ]
}

这是我的 package.json

{
  "name": "game_server",
  "version": "1.0.0",
  "description": "A backend server for the game ",
  "scripts": {
    "test": "mocha -r ts-node/register src/**/*.spec.ts",
    "start": "concurrently \"tsc -p ./src -w\" \"nodemon ./dist/app.js\" "
  },
  "author": "XXXXX",
  "dependencies": {
    "@types/express": "^4.17.6",
    "@types/shortid": "0.0.29",
    "@types/socket.io": "^2.1.4",
    "express": "^4.17.1",
    "shortid": "^2.2.15",
    "socket.io": "^2.3.0",
    "typedeck": "^1.5.2"
  },
  "devDependencies": {
    "@types/chai": "^4.2.11",
    "@types/mocha": "^7.0.2",
    "chai": "^4.2.0",
    "concurrently": "^5.2.0",
    "mocha": "^7.1.2",
    "nodemon": "^2.0.3",
    "ts-node": "^8.10.1",
    "typescript": "^3.9.2"
  }
}

在我的代码中的某个时刻,我使用了一个 for .. of 迭代器来创建一个看起来像

的地图
for (let [key, value] of cardMap) {
}

当我执行 npm run start 时,我的代码编译正常并且服务器启动

但是当我做 npm run test 时扩展到

mocha -r ts-node/register src/**/*.spec.ts

我在上面的行中收到错误

TSError: ⨯ Unable to compile TypeScript:
src/state/GameState.ts:183:30 - error TS2569: Type 'Map<Player, Card[]>' is not an array type or a string type. Use compiler option '--downlevelIteration' to allow iterating of iterators.

183     for (let [key, value] of cardMap) {
                                 ~~~~~~~

我已经尝试将 downLevelIteration=true 合并到我的 tsconfig 中,我是否遗漏了一些让 mocha 测试正常工作的东西?

我开始使用 ts-mocha 并将我的测试脚本更改为 ts-mocha -p ./src/tsconfig.json ./src/**/*.spec.ts,它开始工作了

https://github.com/piotrwitek/ts-mocha#readme