-
Notifications
You must be signed in to change notification settings - Fork 29.9k
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
Docs on http.Server.listen() need clarifications on accepted args #16300
Comments
I could be misunderstanding but doesn't the |
@apapirovski is right, any arguments inside brackets in docs are indicating optional parameters and |
@mscdex @apapirovski thanks for clearing my misunderstanding, effectively the behavior of Flow is inconsistent with what I'll bring it back to the Flow team for discussion. |
Closing because the documentation is clear enough. |
@joyeecheung I'd ask you to leave this open as I believe there are still some inconsistencies. The docs don't specify what is the expected behavior when encountering the signature with one argument // This is interpreted as a port number
server.listen(8080);
// This is interpreted as a port number
server.listen(8080, function callback() {}); which consider the first Additionally, the signature I would like to clarify the expected behavior 😄 |
I would interprete this as "if there is any argument, and the first one is a number ,then the first one is a port" though, I am not sure if this optional argument syntax has any formal standard, but to me the previous arguments can't be optional like that (
I can't really see how the second one can be matched either, for the same reason above. |
@claudiopro OK I think there is another way to make it clearer, although that requires a lot of brackets...
|
Summary: Adds tests for the `http` and `https` modules. Improves the definitions of `server.listen()` to allow omitting intermediate arguments in the `listen(Number, String, Number, Function)` signature, and making all arguments optional. Addresses #1684. See also related discussion on the Node repo: nodejs/node#16300 Closes #5144 Reviewed By: calebmer Differential Revision: D6098963 Pulled By: claudiopro fbshipit-source-id: dae9911842a04fb33ce52491e6f38ddfcd62b8c7
If someone wants to, this could be updated based on the latest feedback from @joyeecheung or instead have a little paragraph that outlines the possible combinations or something. Either way, it's probably a good idea to update with something that's more accurate. |
Hi, @apapirovski. After reviewing the previous comments of this "good first issue" issue, I'm happy to pick up this one and give it a "try" on your reference to the latest feedback from @ joyeecheung with suggestion in your last comment:
Saw your last comment from 14 days ago. So just want to confirm with you again, before I get the local stuff started. I can at least try to start with the proposed signature, learn the proposed parameters with the brackets' syntax, and use my best judgement to write a draft of possible combinations of the signature's parameters, to at least get the draft & PR started. |
@BeniCheni This has actually been addressed by the PR above linked above your comment. Thanks for your interest though! Hope to see you around on another "good first issue". 👍 |
Thanks, @apapirovski. Ah missed the referred PR above my comment. My Bad. 🤗 Will poke around on there “good first time” or “help wanted” labeled open issues. Have a great day! |
This is in relation to facebook/flow#1684
While Flow typing a module that uses
http.Server.listen()
, I received an error for the idiomatic form widely used in Node projects:Flow declares the types of
http.Server.listen()
like this:which adheres to the documentation of the
http
module.Since the
net
module normalizes the arguments and Node itself uses the shorthand forms in the docs on the same page (Event: 'connect', Event: 'upgrade'), I suggest to amend the documentation explaining the shorthand forms are both supported:Thoughts?
The text was updated successfully, but these errors were encountered: