错误 node_modules/jest-diff/build/diffLines.d.ts(8,13):错误 TS1005:预期为“=”。在嵌套 js 中

error node_modules/jest-diff/build/diffLines.d.ts(8,13): error TS1005: '=' expected. in nest js

当我使用 npm run start:dev 命令启动并 运行 nestjs 应用处于监视模式时 然后这个错误显示。

ERROR in node_modules/jest-diff/build/diffLines.d.ts(8,13): error TS1005: '=' expected.
node_modules/jest-diff/build/diffLines.d.ts(8,34): error TS1005: ';' expected.
node_modules/jest-diff/build/index.d.ts(10,13): error TS1005: '=' expected.
node_modules/jest-diff/build/index.d.ts(10,34): error TS1005: ';' expected.
node_modules/jest-diff/build/index.d.ts(11,1): error TS1128: Declaration or statement expected.
node_modules/jest-diff/build/index.d.ts(11,13): error TS1005: ';' expected.
node_modules/jest-diff/build/index.d.ts(11,52): error TS1005: ';' expected.
node_modules/jest-diff/build/printDiffs.d.ts(8,13): error TS1005: '=' expected.
node_modules/jest-diff/build/printDiffs.d.ts(8,57): error TS1005: ';' expected.

您必须在 package.json 文件

中使用最新版本的打字稿更新您的 typescript version

就我而言,我更新为

 "typescript": "^3.9.7"

如果您的打字稿版本是“3.2.4”,请将 jest-diff 降级到 25.5.0 版。这将解决问题。 npm i jest-diff@25.5.0