小编sma*_*ite的帖子

当我使用 jest(ts-jest async/await test) 时,WebStorm 提示我 TS 错误 (TS2705)

包: 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)

javascript webstorm typescript jestjs

1
推荐指数
1
解决办法
1285
查看次数

标签 统计

javascript ×1

jestjs ×1

typescript ×1

webstorm ×1