有属性的函数类型如何定义?

47 阅读1分钟
interface FnWithAttrs {
    attr: string;
    (str: string): void;
}

const test: FnWithAttrs = (str: string) => {
    console.log(str);
}
test.attr = 'attr'