Skip to content
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

Fix @types/superagent has no default export #64

Merged
merged 2 commits into from
Mar 12, 2019

Conversation

scottc
Copy link

@scottc scottc commented Mar 8, 2019

Fix @types/superagent has no default export.
Although this might be an issue with the "@types/superagent": "^4.1.0" type definition.

With typescript "strict": true, config enabled, doesn't allow implicit any type.

TS1192: Module '"C:/_/node_modules/@types/superagent/index"' has no default export.

TS7006: Parameter 'error' implicitly has an 'any' type.

TS7006: Parameter 'response' implicitly has an 'any' type.

@mtennoe
Copy link
Owner

mtennoe commented Mar 11, 2019

Thanks for contributing @scottc!

Looks good! Quick question: Would an updated version of the @types/superagent+superagent packages help address this as well?

@scottc
Copy link
Author

scottc commented Mar 12, 2019

I tried:

@types/superagent@4.1.0 // latest
@types/superagent@4.0.0 // doesn't exist
@types/superagent@3.8.3

superagent@4.1.0 // latest
superagent@4.0.0 // currently used by swagger-typescript-codegen
superagent@3.8.3

All versions listed above export via module.exports = request;
https://github.com/visionmedia/superagent/blob/8580c4f5c4f515fdc2f703b41f0affed4613e958/lib/node/index.js#L47

In ES5, the equivalent of an ES6 default export would be module.exports.default = request;

So I'm inclined to believe that the @types/superagent typedef package is correct / accurate. That there is no default export.

// single import
const get = require('superagent').get;
import { get } from "superagent";
// entire module import
const request = require('superagent');
import * as request from "superagent";
// default import
const request = require('superagent').default;
import request from "superagent";

If this is confusing, might be worth making a pull request to superagent, to expose request as the default export.

@mtennoe
Copy link
Owner

mtennoe commented Mar 12, 2019

Thanks for clarifying!
Might be worth doing the PR against superagent, but not that urgent IMO. If we see confusion around this though we can do that sooner.

Thanks for fixing this!

@mtennoe mtennoe merged commit ab30754 into mtennoe:master Mar 12, 2019
@mtennoe
Copy link
Owner

mtennoe commented Mar 12, 2019

@scottc - Merged and published as 1.9.4

@sbusch
Copy link

sbusch commented Mar 26, 2019

FYI, there's a new major release 5.0.0 for superagent pending, with changes regarding packaging. It could be released soon, possibly in the next few hours. Although I'm no expert, this could impact importing as well. See here: ladjs/superagent#1423

@mtennoe
Copy link
Owner

mtennoe commented Mar 26, 2019

Thanks for the heads up @sbusch! Will be interesting to try out that version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants