How to exclude a key from an interface in TypeScript

后端 未结 4 555
既然无缘
既然无缘 2021-02-05 04:38

In TypeScript, you can combine two interface types like this

interface Foo {
    var1: string
}

interface Bar {
    var2: string
}

type Combined = Foo & Ba         


        
4条回答
  •  花落未央
    2021-02-05 05:00

    interface MyDialogProps extends Omit {
      id: string;
      onClose: (reason: string) => void;
    }
    
    export const MyDialog: React.FC = ({ id, onClose, ...props) => (
       onClose("whatever")} {...props} />
    );
    

提交回复
热议问题