You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
I've updated library inversify-express-utils from 6.3.2 to 6.4.10 and I got this build error
Argument of type 'typeof HttpMyBeautifulMiddleware' is not assignable to parameter of type 'Middleware'.
This happens because Middleware definition changed from (v. 6.3.2) export type Middleware = (inversifyInterfaces.ServiceIdentifier<any> | express.RequestHandler);
to (v. 6.4.10) export type Middleware = (string | symbol | RequestHandler
The new definition is too small to allow all ServiceIdentifier available in Inversify as you can use a prototype or a contructor function as decorator target.
Steps to reproduce
Create an empty inversify express project
Create a class HttpMyBeautifulMiddleware that extends from BaseMiddleware
Register class HttpMyBeautifulMiddleware with .toSelf() method
Create a controller using HttpMyBeautifulMiddleware as middleware with its type definition.
For example @controller('/api/welcome', HttpMyBeautifulMiddleware)
Expected behavior
Build must complete successfully
Possible solution
I suggest to add DecoratorTarget to Middleware definition as you can see below export type Middleware = (string | symbol | RequestHandler | DecoratorTarget<{ handler: RequestHandler }>
This is enough to make build and running complete successfully keeping middleware type checking.
Package version
6.2.1
Node.js version
20.17
In which operating systems have you tested?
macOS
Windows
Linux
Stack trace
No response
Other
No response
The text was updated successfully, but these errors were encountered:
savarex
changed the title
[inversify-espress-utils] Align Middleware type definition to be better compatibile with ServiceIdentifier
Middleware type definition miss DecoratorTarget
Jan 8, 2025
savarex
changed the title
Middleware type definition miss DecoratorTarget
Middleware type definition misses DecoratorTarget
Jan 8, 2025
Is there an existing issue for this?
Current behavior
Hi,
I've updated library inversify-express-utils from 6.3.2 to 6.4.10 and I got this build error
Argument of type 'typeof HttpMyBeautifulMiddleware' is not assignable to parameter of type 'Middleware'.
This happens because Middleware definition changed from (v. 6.3.2)
export type Middleware = (inversifyInterfaces.ServiceIdentifier<any> | express.RequestHandler);
to (v. 6.4.10)
export type Middleware = (string | symbol | RequestHandler
The new definition is too small to allow all ServiceIdentifier available in Inversify as you can use a prototype or a contructor function as decorator target.
Steps to reproduce
For example
@controller('/api/welcome', HttpMyBeautifulMiddleware)
Expected behavior
Build must complete successfully
Possible solution
I suggest to add DecoratorTarget to Middleware definition as you can see below
export type Middleware = (string | symbol | RequestHandler | DecoratorTarget<{ handler: RequestHandler }>
This is enough to make build and running complete successfully keeping middleware type checking.
Package version
6.2.1
Node.js version
20.17
In which operating systems have you tested?
Stack trace
No response
Other
No response
The text was updated successfully, but these errors were encountered: