Type Alias: DecorateAcknowledgements<E>
ts
type DecorateAcknowledgements<E> = {
[K in keyof E]: E[K] extends (args: infer Params) => infer Result
? (args: PrependTimeoutError<Params>) => Result
: E[K];
};Utility type to decorate the acknowledgement callbacks with a timeout error.
This is needed because the timeout() flag breaks the symmetry between the sender and the receiver:
Type Parameters
| Type Parameter |
|---|
E |
Example
ts
interface Events {
"my-event": (val: string) => void;
}
socket.on("my-event", (cb) => {
cb("123"); // one single argument here
});
socket.timeout(1000).emit("my-event", (err, val) => {
// two arguments there (the "err" argument is not properly typed)
});