-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
Move @jest/types
to dev dependencies
#10937
Conversation
Hi @fedyk! Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It needs to be a dependency otherwise TypeScript compilation will fail.
I don't know how to best deal with globals in differing environments. This is an issue for TS to figure out I believe.
microsoft/TypeScript#33111
microsoft/TypeScript#37775
@orta is this something the TS team is looking into/have a good workaround for? The two issues I found didn't have much traffic
We've come up with a bunch of ideas, and keep dismissed them as infeasible at scale (either through complexity, or putting too much onus on individuals o line things up perfectly which won't happen). https://gist.github.com/RyanCavanaugh/702ebd1ca2fc060e58e634b4e30c1c1c is the latest idea which hasn't been disproven yet - that said, I wouldn't bet on it landing anytime soon. For the long term, I'd recommend something like this PR, more importantly I'd look into weakening the external 'user-facing' Jest types to remove any explicit node references if possible. The same conflict would exist inside electron, or react native apps too for example. |
Thanks for the link @orta, that looks really promising! Having the Not sure how we can make our own types less exact though - main issue is where we expose e.g. |
Would just using optional peer dep work? I assume TS will just explode due to a |
@SimenB I think it might work if the user's tsconfig has But if it doesn't then I think you are right, TS won't like it. |
Hmm. Is it not possible to just move |
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Summary
The
@jest/types
has@types/node
as dependency. As a result, after installing the recent version ofpretty-format
, TypeScript thinks that my web app is nodejs. The main problem is the timers. Innodejs
they returnTimeout
object. In browser it returns a number: