-
-
Notifications
You must be signed in to change notification settings - Fork 527
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
Request assistance with nyc to ts-node/register incompatibility #813
Comments
@coreyfarrell Hmm, I've always used The workarounds I see are:
I'll keep thinking a little on 2, but nothing comes to mind right now as a workaround with annotating it explicitly with TypeScript types. |
I want the wrapper code to be tolerated as TypeScript, it does need to be valid JavaScript though (this is first priority). I think the idea behind instrumenting the TypeScript before transpiling it is to avoid generated branches. I'm unsure what you mean about I'm not sure about detecting that we're in TypeScript. Maybe we could omit the |
Yes.
Probably, that would be point 1. You'd need to submit an issue to TypeScript though. |
Related to microsoft/TypeScript#3841. Edit: It may be enough for now to submit a PR changing https://github.com/Microsoft/TypeScript/blob/3f3444be80dc939eb20db52fa98a206dba31e077/src/lib/es5.d.ts#L252 to add |
I found the best immediate solution. We inject the coverage from a babel callback Thanks for helping me understand this and linking me to the TypeScript issue. |
I'm an nyc maintainer working on istanbuljs/nyc#1002. I already have a patch in review to address the issue with
coverageData.hash = hash;
. I have not found a solution forerror TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.
. The instrumented code always contains:Worth noting
node -e 'console.log(Function === function() {}.constructor);'
will print true, unfortunately it's possible (in JavaScript) forFunction
to be redefined. For example the following logs false to the console:I've tried the following:
The hope was that in a TypeScript project nobody would have replaced
Function
, soglobalFinder
would be set toFunction
. ts-node still rejected this code with the same error. Would it be possible for ts-node/register to understand thatfunction () {}.constructor === Function
? I'd like to make it easier to get code coverage for projects usingts-node/register
, any suggestion would be appreciated.The text was updated successfully, but these errors were encountered: