Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Give typings to global.__coverage__ to avoid @ts-ignore #18

Merged
merged 1 commit into from Dec 8, 2019
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

give typings to global.__coverage__ to avoid @ts-ignore

  • Loading branch information
rhysd committed Dec 2, 2019
commit c696561d4377e63b9c30a8f3359d556249fca0a6
@@ -0,0 +1,11 @@
declare module NodeJS {
interface Global {
__coverage__: {
[filePath: string]: {
s: { [n: string]: number };
f: { [n: string]: number };
b: { [n: string]: number[] };
};
};
}
}
@@ -19,22 +19,15 @@ class Worker {

getTotalCoverage() {
let total = 0;
// @ts-ignore
for (const filePath in global["__coverage__"]) {
// @ts-ignore
for (const s in global["__coverage__"][filePath]['s']) {
// @ts-ignore
total += global["__coverage__"][filePath]['s'][s] ? 1 : 0;
for (const filePath in global.__coverage__) {
for (const s in global.__coverage__[filePath].s) {
total += global.__coverage__[filePath].s[s] ? 1 : 0;
}
// @ts-ignore
for (const f in global["__coverage__"][filePath]['f']) {
// @ts-ignore
total += global["__coverage__"][filePath]['f'][f] ? 1 : 0;
for (const f in global.__coverage__[filePath].f) {
total += global.__coverage__[filePath].f[f] ? 1 : 0;
}
// @ts-ignore
for (const b in global["__coverage__"][filePath]['b']) {
// @ts-ignore
for (const i of global["__coverage__"][filePath]['b'][b]) {
for (const b in global.__coverage__[filePath].b) {
for (const i of global.__coverage__[filePath].b[b]) {
total += i ? 1 : 0;
}
}
@@ -44,8 +37,7 @@ class Worker {
}

dump_coverage() {
// @ts-ignore
const data = JSON.stringify(global["__coverage__"]);
const data = JSON.stringify(global.__coverage__);
if (!fs.existsSync('./.nyc_output')){
fs.mkdirSync('./.nyc_output');
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.