typescript 如何 给默认的接口 覆盖一个属性?

这是 vue 框架自带的接口定义

export declare interface DirectiveBinding<V = any> {
    instance: ComponentPublicInstance | null;
    value: V;
    oldValue: V | null;
    arg?: string;
    modifiers: DirectiveModifiers;
    dir: ObjectDirective<any, V>;
}

我定义了如下一个函数

interface MyInterface{
    value:Function
}

const focus = (data:这里怎么写?)=>{
    data.value() // 其中我的 value 必须要传一个函数
}

我想用我的 MyInterface 覆盖 DirectiveBindingvalue

阅读 1.9k
1 个回答

type MyInterface<T = any> = Omit<DirectiveBinding<T>, 'value'> & {value: Function}

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题