我遇到错误
错误TS1241:作为表达式调用时,无法解析方法装饰器的签名。”当我使用注释'@httpGet('/ product')
我导入了以下软件包:
"express": "^4.17.1",
"inversify": "^5.0.1",
"inversify-express-utils": "^6.3.2"
我的代码是:
import { controller, httpGet, request, response } from "inversify-express-utils";
import { Request, Response } from "express";
@controller("")
export class ProductController implements IProductController {
@httpGet('/product')
async get(@request() req: Request, @response() res: Response) {
....
}
}
有人遇到过同样的问题吗?
答案 0 :(得分:0)
控制器注释必须是路线的名称,get
注释要求您指定查询参数,如果没有,则仅指定/
。还可以尝试将interfaces.Controller用作基类。例如,尝试以下代码
import { interfaces, controller, httpGet, request, response } from "inversify-express-utils";
import { Request, Response } from "express";
@controller("/product")
export class ProductController implements interfaces.Controller {
@httpGet('/')
async get(@request() req: Request, @response() res: Response) { ... }
@httpGet('/:productId')
async get(@request() req: Request, @response() res: Response) { ... }
}