【发布时间】:2020-12-22 05:02:56
【问题描述】:
我正在尝试使用 Visual Studio Code 和 mocha 调试单元测试,但是当 mocha 启动时,会引发此错误。
TSError: ⨯ 无法编译 TypeScript: mfa/test/index.test.ts(4,20): 错误 TS2307:找不到模块“断言”或其对应类型 声明。
我的launch.json:
{
"version": "0.2.0",
"configurations": [
{
"name": "mocha tests",
"type": "node",
"protocol": "inspector",
"request": "launch",
"program": "${workspaceRoot}/node_modules/mocha/bin/_mocha",
"stopOnEntry": false,
"args": [ "-r", "ts-node/register", "${workspaceRoot}/test/**/*.test.ts", "--no-timeouts"],
"sourceMaps": true,
"cwd": "${workspaceRoot}"
}
]
}
我的 tsconfig.json
{
"compilerOptions": {
"experimentalDecorators": true,
"target": "ES2017",
"module": "commonJs",
"allowJs": false,
"sourceMap": true,
/* Strict Type-Checking Options */
"strict": true,
"noImplicitAny": false,
"esModuleInterop": true,
/* Advanced Options */
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
}
}
【问题讨论】:
标签: typescript visual-studio-code mocha.js