Fix the getHeaders method signatures#434
Fix the getHeaders method signatures#434mapleeit merged 3 commits intoform-data:masterfrom ScriptSmith:master
Conversation
|
Hi @ScriptSmith Thank you for your patch and sorry for the late reply. (I missed this) I'm not sure the type of input param is just I guess it may be @alexindigo Do you still remember the reason why adding |
|
Good point, I think Regarding |
|
So how should I think it should just look at the object's keys, and not up the prototype chain. Therefore it makes sense to keep the I also think it shouldn't be picky about the types of header values, even though internally it only makes sense for them to be strings / numbers, because I think other users are relying on the non-standard Lines 295 to 297 in 5c6bf52 Therefore I think it should just use the simple definition that's already included, rather than any of the header definitions in What do you think @mapleeit? |
|
@ScriptSmith Agree with that. |
In the readme,
getHeadersis described as accepting and returning an array:The function doesn't return an array, and while it can technically accept one, the output it produces doesn't seem useful:
form-data/lib/form_data.js
Lines 293 to 306 in 905f173
Here's how it's defined in index.d.ds:
form-data/index.d.ts
Line 14 in 905f173
form-data/index.d.ts
Lines 26 to 29 in 905f173
This is more correct, but it says that
getHeadersdoesn't take any arguments, which is incorrect.I've updated the readme to say that it takes and returns
Headersas defined inindex.d.ts(but perhaps it should be something more generic likeObject). I've also updated the type definitions to include theuserHeadersparameter.Furthermore, line 300 in
getHeadersseems redundant:form-data/lib/form_data.js
Line 300 in 905f173
It was added in ebf47ef because of an issue identified in codacity? / codacy. I'm not sure what problem this could be mitigating.
If it is redundant I'll add another commit to correct it.