Typescript 将NonuUsedLocals添加到tsconfig.json报告我所有测试的假阳性(mocha)
tsconfig.jsonTypescript 将NonuUsedLocals添加到tsconfig.json报告我所有测试的假阳性(mocha),typescript,mocha.js,Typescript,Mocha.js,tsconfig.json { "compilerOptions": { "module": "commonjs", "target": "es6", "typeRoots": [ "./node_modules/@types" ], "moduleResolution": "node", "noUnusedParameters": true, "noUnusedLocals": true }, "exclude": [
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"typeRoots": [
"./node_modules/@types"
],
"moduleResolution": "node",
"noUnusedParameters": true,
"noUnusedLocals": true
},
"exclude": [
"./lib/**/*",
"./node_modules/**/*"
],
"include": [
"./src/**/*",
"./test/**/*"
]
}
命令
tsc-w-p tsconfig.json--noEmit
当我运行这个程序时,我得到了所有类型的“声明但从未使用过”,但只有在我的摩卡测试中
我在src中的普通代码工作得很好,如果我不使用某个导入或变量,它会像应该的那样抱怨
谢谢您可以添加一个最小的测试用例吗?什么var是声明的且从未使用过的。我发现了问题。发生的事情是,有一些未使用的导入,但我的编辑器没有标记它们。我修复了它们,现在它可以编译了。看,有时候你只需要远离一个问题