【发布时间】:2018-10-12 15:11:58
【问题描述】:
是否可以为装饰器函数编写类型签名(我的意思是装饰器设计模式装饰器,而不是打字稿装饰器功能)?
我试过了:
function decorate<T extends () => any>(callback: T): T {
return (...args) => {
console.log('called with args: ', args);
return callback(...args);
};
}
但它给了我TS2322: Type '(...args: any[]) => any' is not assignable to type 'T'.
【问题讨论】:
标签: typescript