我有一个函数装饰器,例如:
// Just to have an example of a decorator that changes the type
type Foo<T> = T;
type Bar<T> = T;
function someDecorator<T, U extends unknown[]>(fn: (...args: U) => Foo<T>) : (...args: U) => Bar<T> {
return fn;
}
我想将该装饰器应用于模块中的每个函数:
export function decorateModule(m : any) {
let newModule = {} as any;
Object.keys(m).forEach(function(k) {
newModule[k] = someDecorator(m[k]);
});
return newModule;
}
decorateModule的类型是什么(没有any
)?