【发布时间】:2020-06-11 21:11:59
【问题描述】:
我将一个中间件注入到一个模块中。
我在调用consumer.apply(middleware) 时遇到类型错误:
代码:
@Module({
...
})
export class FooModule implements NestModule {
@Inject(FOO_MIDDLEWARE)
private middleware: NestMiddleware;
public configure(consumer: MiddlewareConsumer) {
consumer
.apply(this.middleware)
.forRoutes('foo');
}
}
错误:
TS2345: Argument of type 'NestMiddleware<any, any>' is not assignable to parameter of type 'Function | Type<any>'. Type 'NestMiddleware<any, any>' is missing the following properties from type 'Type<any>': apply, call, bind, prototype, and 5 more.
【问题讨论】:
标签: typescript nestjs