不带lambda的函数引用的TypeScript泛型绑定
是否可以在TypeScript函数引用中绑定泛型参数不带lambda的函数引用的TypeScript泛型绑定,typescript,typescript-generics,Typescript,Typescript Generics,是否可以在TypeScript函数引用中绑定泛型参数 例如,我有一个定义为膝关节炎的中间件: const genericsMiddleware: <T extends MyType>(ctx: MyRouterContext<T>) => Promise<any> = <T extends MyType>(ctx: MyRouterContext<T>) => Promise.resolve(ctx.body
例如,我有一个定义为膝关节炎的中间件:
const genericsMiddleware: <T extends MyType>(ctx: MyRouterContext<T>) => Promise<any> =
<T extends MyType>(ctx: MyRouterContext<T>) =>
Promise.resolve(ctx.body.value);
router.post('/api/endpoint',
someOtherMiddleware,
genericsMiddleware); // How to bind to certain type?
router.post('/api/endpoint',
someOtherMiddleware,
(ctx) => genericsMiddleware<TypeDef>(ctx)); // This works but lambda is useless
而不是
R.pipe(
R.map(mappingFunction),
R.flatten<string>
)(data)
R.pipe(
R.map(映射功能),
拉平
)(数据)
R.pipe(
R.map(mappingFunction),
R.flatten<string>
)(data)