![](/img/trans.png)
[英]Class Name prop value error: left side of comma operator is unused and has no side effects
[英]ts-mocha and chai - error TS2695: Left side of comma operator is unused and has no side effects
工具/库版本:
"ts-mocha": "^8.0.0",
"ts-node": "^10.3.0",
"chai": "^4.3.4",
代码:
expect(wrapper.find(MyListItem)).to.have.length(3);
命令:
ts-mocha tests/**/*.tsx -r unitTestSetup.ts
我的打字稿编译器选项:
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"declaration": true,
"outDir": "./lib",
"strict": true,
"esModuleInterop": true,
},
错误:
tests/index.spec.tsx:41:10 - error TS2695: Left side of comma operator is unused and has no side effects.
41 (0, chai_1.expect)(wrapper.find(MyListItem)).to.have.length(3);
这似乎是由于未安装 ts-mocha 的可选依赖项造成的。 ( tsconfig-paths
)
有没有比在 ts-mocha 包上执行npm install --force
来强制它安装 tsconfig-paths 更好的方法来解决这个问题? (我提供的答案)
我通过在我的package.json
文件中创建一个“fix-ts-mocha”脚本来解决这个问题:
"fix-ts-mocha": "cd node_modules && cd ts-mocha && npm install --force"
我在npm install
之后运行一次(或者每次更新ts-mocha
时)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.