-
-
Notifications
You must be signed in to change notification settings - Fork 734
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
How to import nock in TypeScript #1589
Comments
(Sorry if this is not the best place to post it but I intuitively searched this repo for "TypeScript" and googled as well, without much luck. Feel free to close.) |
There could be discussion around whether we want to support export index.js could be updated to have this const scope = require('./lib/scope')
module.exports = scope
module.exports.default = scope |
Would be a welcome change for sure 😄 |
... and to extend on @borekb summary:
|
That's the first thing I usually try but it doesn't work for me:
Again, this is in the context of Babel (Jest tests). It works via ts-node. |
Hmm, this seems a bit hacky solution for this problem which is an ecosystem issue. Is it possible there is a problem with the types that is contributing to the difficulty with |
It's true that I'm fighting with this because of how Babel + TypeScript play together but it's a significant enough stack & the change for Nock would be small so I think it would be worth it. |
Just a note for anyone googling this (I had a hard time...):
This syntax is used in DefinitelyTyped tests:
However, it doesn't work with Babel (in our case, Jest uses Babel under the covers):
This is the recommended syntax:
But that yielded another error when starting the app via ts-node:
It started working when I added
"esModuleInterop": true
totsconfig.json
.Summary:
import nock from 'nock'
"esModuleInterop": true
totsconfig.json
The text was updated successfully, but these errors were encountered: