【问题标题】:Jest / Ts-Jest / Babel : Debug Failure. False expression: Output generation failedJest / Ts-Jest / Babel:调试失败。错误表达式:输出生成失败
【发布时间】:2018-09-11 20:47:48
【问题描述】:

使用 TypeScript 2.8,我们现在可以仅从源文件生成 .d.ts。所以我的 tsconfig.json 变成了:

{
  "compilerOptions": {
    "allowSyntheticDefaultImports": true,
    "module": "commonjs",
    "target": "es5",
    "lib": ["ES6","ES2017","ESNext"],
    "downlevelIteration": true,
    "moduleResolution": "node",
    "declaration": true,
    "emitDeclarationOnly": true,
    "declarationDir": "./lib"
  },
  "exclude": [
    "node_modules"
  ],
  "include": [
    "src/**/*"
  ],
  "strict": true
}

问题是构建被破坏了(https://travis-ci.org/jy95/mediaScan/jobs/359573738)。 我的回购:https://github.com/jy95/mediaScan/tree/prettier

任何想法如何解决它?

我的 jest.config.js :

// jest.config.js
module.exports = {
    verbose: true,
    "moduleFileExtensions": [
        "ts",
        "tsx",
        "js"
    ],
    "transform": {
        "^.+\\.tsx?$": "ts-jest"
    },
    "testMatch": [
        "<rootDir>/__tests__/**/*.(ts|tsx|js)"
    ],
    "testPathIgnorePatterns": ["<rootDir>/node_modules/", "<rootDir>/__tests__/__helpers__/"],
    "collectCoverage": true
};

谢谢

【问题讨论】:

    标签: node.js typescript babeljs jestjs


    【解决方案1】:

    我在切换jest 以使用ts-jest 而不是babel-jest 处理.js 文件时遇到了类似的问题。

    typescript.js 中的getConstructorDefinedThisAssignmentTypes 发生错误(根据堆栈跟踪)。并且很可能是由不正确或缺少类型引起的。在此处添加一些断点或日志类型/声明以查看到底是什么失败了。

    您可以尝试将typescript 升级到最新版本,它可能会给出更有价值的错误消息,并尝试tsc --noEmit 看看您的类型是否有一些漏洞。

    有时npx jest --clearCache 也有帮助

    【讨论】:

      猜你喜欢
      • 2019-12-09
      • 1970-01-01
      • 1970-01-01
      • 2023-03-08
      • 1970-01-01
      • 2020-01-15
      • 2018-02-22
      • 2021-02-14
      • 2021-04-04
      相关资源
      最近更新 更多