-
Notifications
You must be signed in to change notification settings - Fork 2
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
Comment typings with documentation #5
Comments
I totally agree. I've copied this one from DT without changing anything really. I always copy everything from docs as I write typings. e.g. node-uuid I wrote recently. |
Right, it's the same for me. |
Nice, thank you. |
Okay, so I ran in some new issues again with the result of Even if |
Hmm. I don't see how you can possibly get that as it's only ever used here response.toJSON = responseToJSON and here. Request.prototype.toJSON = requestToJSON Can you show me how to reproduce that? I totally agree. I think rewriting everything is a good idea as there are some deprecated options still in the declaration file (like |
I am trying to convert a lib to Typescript so I don't know myself how it ends up receiving the JSON value (I am currently investigating it), I let you know once I found. It's something like: var options = {
headers: getHeaders(url),
timeout: 60000,
qs: qs,
url: url,
method: "GET",
jar: jar,
gzip: true
};
request(options, (err, res, body) => {
// and here, res has all the attributes of the function I linked
}); You're right about the code, I may have spoken a bit too fast: it's hard to maintain. But maybe adding some of our own comments or some pseudo-js to clarify edge cases could be useful. |
I finally found some time for this issue, here is a test I made: const URL = "https://api.typings.org/entries/npm/request";
let options: request.CoreOptions & request.UriOptions = {
headers: {},
timeout: 60000,
qs: {},
uri: URL,
method: "GET",
jar: null,
gzip: true
};
request(options, (error, response, body) => {
if (error) {
return null;
}
console.log(Object.keys(response));
}); This does return: [
'_readableState',
'readable',
'domain',
'_events',
'_eventsCount',
'_maxListeners',
'socket',
'connection',
'httpVersionMajor',
'httpVersionMinor',
'httpVersion',
'complete',
'headers',
'rawHeaders',
'trailers',
'rawTrailers',
'upgrade',
'url',
'method',
'statusCode',
'statusMessage',
'client',
'_consuming',
'_dumped',
'req',
'request',
'toJSON',
'caseless',
'read',
'body'
] So in the end, I do not receive a Here are the ones responsible for |
I don't really know what to do about these methods and properties. They are not documented anywhere but I found some repos using them as I told you. |
I asked more informations about these properties on the I haven't done a PR yet, but I started to work on this branch. The main changes for the moment are about replicating a part of the structure of the source package as discussed here. I prefer to add some tests before submitting a PR. (The changes are non-breaking) I was also confused at first about the way this module exposes its static API with a generic, but now I get it. |
So caseless looks like a copy of the whole object with case insensitive keys (like headers).
it's apparently used internally like here. Also response is an instance of request(options, (error, response, body) => {
if (error) {
return null;
}
console.log(require('util').inspect(response));
});
// > IncomingMessage {
// ...
// } I agree. Let's only add documented features. Looking forward to seeing it 😉 |
I have some good news, the team behind References: |
I'm closing this issue because it is no longer relevant. There are better issues on the Request repos and and |
We should adopt the style of other typings and include the related documentation in the comments.
It would greatly help in providing context to the typings: it's convenient to jump straight to the definitions and read the doc. This would be a first step in the direction of integrating documentation.
It would also have prevented issues such as #3.
The text was updated successfully, but these errors were encountered: