-
-
Notifications
You must be signed in to change notification settings - Fork 532
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
Warn on noEmitHelpers: true
because is likely to cause problems; causes unhelpful error
#1691
Comments
noEmitHelpers: true
noEmitHelpers: true
What's the use-case for setting I've been hesitant to add error-detection logic because I'm not sure of the performance impact nor of our ability to reliably intercept errors in nodejs. If we can perform some sort of validation check on your configuration at bootup, and warn when your tsconfig has this flag set, I think that might be easier to implement, have better performance, and be just as useful to you. |
There are a bunch of issues that can be detected by setting If you're using We might also be able to force |
Yes, exactly. https://github.com/getsentry/sentry-javascript (We're backend, too, of course, but you're correct that
I can't speak to the performance aspect, but I do know a thing or two about intercepting errors! Happy to consult if you decide to go that route. I think it could be as simple as wrapping the global error handler (and/or try-catching whatever code throws here), checking the message for the names of any of the tslib functions (there aren't that many), and pointing people to a docs page with tslib troublshooting.
Yup. We're actually in process of transitioning to that right now! getsentry/sentry-javascript#4497 That's on a branch, but will get pulled in soon. Interesting, though. So I wouldn't have run into this at all had I happened to be working on my current PR three weeks from now? Good to know, LOL.
Sure, that could work, too! Thanks for taking a look at this! |
Yeah, any wisdom you can share would be great. I did a bit more thinking about this. If we went the error-catching route, we'd need to catch stuff that happens async as well.
By "global error handler", are you referring to It appears to emit before the error? So I guess from the user's perspective, they'd see our warning appear just above the error. I think, in the interest of reducing implementation effort and complexity, I'll go for validating the tsconfig, detecting But there are a bunch of other warning ideas in #1504, and some of those might be better candidates for intercepting and matching well-known error messages. |
noEmitHelpers: true
noEmitHelpers: true
because is likely to cause problems; causes unhelpful error
I was thinking about
Sounds good! |
Search Terms
ReferenceError: __values is not defined
tslib
noEmitHelpers
importHelpers
Expected Behavior
An error message which helps me solve the problem. Could be something along the lines of what's described in #1504 (When transpiled code attempts to require tslib, regenerator-runtime, or @swc/helpers, log a helpful warning about adding those dependencies; link to relevant docs page), making sure to include this case in the docs, or could be logic to actually detect this situation and suggest a solution.
Specifically, the problem here is that
noEmitHelpers
meanstslib
helpers aren't included during compilation. Normally that's fine, as long as you haveimportHelpers
turned on, but if you have no other imports or exports (require
calls don't count),importHelpers
does you no good, even withtslib
added as an explicit dependency. The solution (in my case) was to convert myrequire
s toimport
s, which I hadn't yet gotten around to in converting my script from JS to TS. (Presumably turning offnoEmitHelpers
would also work.) This is the comment which finally saved me.Actual Behavior
The raw error, with no explanation, not even that this is a
tslib
problem:Steps to reproduce the problem
tslib
helper when down-compilednoEmitHelpers
set totrue
in yourtsconfig
ts-node
Minimal reproduction
(See also TypeStrong/ts-node-repros#26)
example.ts:
tsconfig.json:
Then run:
Specifications
Versions:
tsconfig.json:
Operating system and version: OS X 12.2.1
The text was updated successfully, but these errors were encountered: