-
Notifications
You must be signed in to change notification settings - Fork 1.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
Error when calling listen
on Node's http
server
#1684
Comments
I have the same problem as well! Why there's no one looking at this problem? @nthtran |
@nthtran FYI the link you provided (http://tryflow.org/#6b0a9f9d52c7320c9e9de182fa081c55) does not illustrate the error (anymore) |
the issue seems to be that the listen(port: number, hostname?: string, backlog?: number, callback?: Function): Server; So if there is a second argument provided to listen(path: string, callback?: Function): Server; Which does expect the second parameter to be a Function, but does not match as the first provided argument is a You could 'solve' this by explicitly provided server.listen(3000, undefined, undefined, () => {}); |
@bakotaco That solved my problem! THANKS! |
@mroch ugly as hell but this definition seems to work: declare var listen:
((port?: number, hostname?: string, backlog?: number, callback?: Function) => void) &
((port?: number, hostname?: string, callback?: Function) => void) &
((port?: number, backlog?: number, callback?: Function) => void) &
((port?: number, callback?: Function) => void) &
((hostname?: string, backlog?: number, callback?: Function) => void) &
((hostname?: string, callback?: Function) => void) &
((backlog?: number, callback?: Function) => void) &
((callback?: Function) => void) The downside is that the error messages are loooooooong. Should I make a PR or no? Alternatively, assuming that invalid arguments will just be ignored by the implementation, perhaps it would be best to change the signature to just |
@mroch proposal: use declare module fs {
declare function writeFile(
file: string | Buffer | number,
data: string | Buffer,
options??: Object | string,
callback?: (err: ?ErrnoError) => void
): void;
} |
…ions 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 facebook#1684.
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 facebook#1684.
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 facebook#1684.
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
flow
has support for Node'shttp
module. However callinglisten
on aServer
instance causes an error that shouldn't exist. Given the following code:The error is:
You can see this on tryflow.org:
http://tryflow.org/#6b0a9f9d52c7320c9e9de182fa081c55
The text was updated successfully, but these errors were encountered: