当它编译我的代码时,TypeScript 在每个文件的顶部包含一个 __extends 声明:
var __extends = this.__extends || function (d, b) {
/* istanbul ignore next */
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
__.prototype = b.prototype;
d.prototype = new __();
};
这在幕后工作得很好,但是在使用 karma-coverage 之类的东西来生成报告时会产生不一致。该声明包含两个函数调用和代码中的一个分支(|| 用法),它们只会在第一个声明中执行,留下数十个(如果不是数百个)后续声明没有覆盖。这使得具有 100% 代码覆盖率的文件在覆盖率报告中看起来很糟糕。
有没有人解决过这个问题?