I want to create a promise which settles when a WebSocket connects.
import * as WebSocket from "ws"
let ws = WebSocket("ws://example.com")
function foo(echo: string) {
return new Promise((resolve, reject) => ws.once("open", () => resolve(echo)));
}
In VS Code, the foo function infers as yielding Promise<{}>
.
- What a
Promise<{}>
? - More generally, how do I get this to refer a
Promise<string>
? Am I misunderstanding Trigger Promise when an event fires ?