zl程序教程

您现在的位置是:首页 >  前端

当前栏目

[Typescript] Extends and override an existing interface

typescript and an interface override existing extends
2023-09-14 08:59:12 时间

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
}