You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The code executed by Jest with --coverage is incorrect when using TS private arguments. It seems to be transpiled as such, which isn't valid because this can only be used after the super call:
classBar{}/* istanbul ignore next */cov_s64sx2cd4.s[0]++;exports.Foo=classFooextendsBar{constructor(arg){/* istanbul ignore next */this.arg=arg;cov_s64sx2cd4.f[0]++;cov_s64sx2cd4.s[1]++;super();}};
Interestingly, it works if I "transpile" the construct myself. The generated code becomes:
classBar{}/* istanbul ignore next */cov_s64sx2cd4.s[0]++;exports.Foo=classFooextendsBar{constructor(arg){/* istanbul ignore next */cov_s64sx2cd4.f[0]++;cov_s64sx2cd4.s[1]++;super();/* istanbul ignore next */cov_s64sx2cd4.s[2]++;this.arg=arg;}};
To Reproduce
Code that triggers the bug:
class Bar {
}
class Foo extends Bar {
constructor(
private arg: number,
) {
super();
}
}
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.
馃悰 Bug Report
The code executed by Jest with
--coverage
is incorrect when using TS private arguments. It seems to be transpiled as such, which isn't valid becausethis
can only be used after thesuper
call:Without
--coverage
it gets transpiled as such:Interestingly, it works if I "transpile" the construct myself. The generated code becomes:
To Reproduce
Code that triggers the bug:
Expected behavior
Should work, but doesn't
Link to repl or repo (highly encouraged)
https://github.com/arcanis/jest-coverage-ts
Run
npx envinfo --preset jest
Paste the results here:
The text was updated successfully, but these errors were encountered: