包: jest ts-jest @types/jest
IDE:WebStorm
当我使用jest异步测试时,有一个我无法解决的 TS 错误 (TS2705)。但是这个提示不影响jest命令。

当我使用最小的测试时也有同样的错误:
import {} from 'jest';
test('async test',async ()=>{
});
Run Code Online (Sandbox Code Playgroud)
开玩笑的配置文件
module.exports = {
"transform": {
"^.+\\.tsx?$": "ts-jest"
},
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$",
"moduleFileExtensions": [
"ts",
"tsx",
"js",
"jsx",
"json",
"node"
],
globals:{
'ts-jest':{
// I have the same behavior when I delete this line
"tsConfigFile": "./tsconfig.json"
}
}
};
Run Code Online (Sandbox Code Playgroud)
配置文件
{
"compilerOptions": {
"types": [
"node"
],
"module": "commonjs",
"target": "es2017",
"lib": [
"es2015",
"es2016",
"esnext.asynciterable"
],
"noImplicitAny": false, …Run Code Online (Sandbox Code Playgroud)