[Typescript] Extends and override an existing interface

For example, you have an object `A`, you want to extend it and modify some prop; then create a new interface B:

export interface B extends Omit<A, 'x' | 'y'> {
  x: string;          // override x
  y: number;          // override y
  newProp?: string;   // add new prop
}

 

 

posted @ 2021-08-05 17:58  Zhentiw  阅读(97)  评论(0编辑  收藏  举报