mirror of
https://github.com/socketio/socket.io.git
synced 2026-01-10 07:28:06 -05:00
refactor(types): ensure compatibility with Express middlewares
In order to prevent issues like:
> error TS2345: Argument of type 'RequestHandler<ParamsDictionary, any, any, ParsedQs, Record<string, any>>' is not assignable to parameter of type 'Middleware'.
> Types of parameters 'req' and 'req' are incompatible.
> Type 'IncomingMessage' is missing the following properties from type 'Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>': get, header, accepts, acceptsCharsets, and 29 more.
>
> io.engine.use(sessionMiddleware);
~~~~~~~~~~~~~~~~~
Related: https://github.com/socketio/socket.io/issues/4644
We could also have use the RequestHandler type from the
@types/express-serve-static-core package, but that would add 5 new
dependencies.
See also: https://github.com/socketio/engine.io/issues/673
This commit is contained in:
@@ -320,7 +320,7 @@ export abstract class BaseServer extends EventEmitter {
|
||||
*
|
||||
* @param fn
|
||||
*/
|
||||
public use(fn: Middleware) {
|
||||
public use(fn: any) {
|
||||
this.middlewares.push(fn);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user