0
我通常有这样的代码,但TS不能推断函数参数的类型,因为它不知道上下文。通过提示打字稿推断函数参数类型
有什么办法来提示编译器类型的功能?
router.get('/get', imget);
router.get('/send', imsend);
function imget(req, res, next) { }
function imsend(req, res, next) { }
export = router;
我尝试了不同类型的断言,但所有这些导致语法错误。
喜欢的东西:
function imget(req, res, next) { } as express.RequestHandler
但它可以防止功能提升! :( – OwnageIsMagic