I am trying to use supertest with TypeScript after initially using with JavaScript.
However I am now receiving red squiggles under my code stating:
cannot invoke expression whose type lacks a call signature. Type 'typeof supertest' has no compatible call signatures
I am using supertest in the following way:
import * as supertest from 'supertest';
const request = superTest(some.url);
// Forgive my pseudocode
function makeRequest() {
return request.get('/endpoint')...
}
Is this something I should be worried about? How can I correct this?
I had the @types/supertest added (as suggested by the other answer) but doing the following solved the problem:
import supertest like this:
import supertest from 'supertest';
in my index.ts file, export the value of app.listen(...); like following (previously it was export default server):
export {server};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With