是否可以使用ts装饰器来推断方法的签名?像这样:
interface Events {
ready: (msg: string) => any;
close: (msg: string) => any;
count: (num: number) => any;
}
function BindEvent<K extends keyof Events>(event: K) {
return function(target, method, descriptor) {
// do something
} as Events[K];
}
class MyClass {
@BindEvent<'ready'>('ready')
public myMethod() // => (msg: string) => any
}