Skip to content

Commit

Permalink
refactor(types): ensure compatibility with Express middlewares
Browse files Browse the repository at this point in the history
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);
                 ~~~~~~~~~~~~~~~~~

We could also have use the RequestHandler type from the
@types/express-serve-static-core package, but that would add 5 new
dependencies.
  • Loading branch information
darrachequesne committed May 1, 2023
1 parent cb1eb6d commit 04b881c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/server.ts
Expand Up @@ -320,7 +320,7 @@ export abstract class BaseServer extends EventEmitter {
*
* @param fn
*/
public use(fn: Middleware) {
public use(fn: any) {
this.middlewares.push(fn);
}

Expand Down

0 comments on commit 04b881c

Please sign in to comment.