Extending a generic parameter in Typescript

前端 未结 2 1200
醉梦人生
醉梦人生 2020-12-21 03:52

I want to create a utility function which creates a checklist by adding an isChecked knockout observable property to each item in an array. This function should

2条回答
  •  臣服心动
    2020-12-21 04:18

    Since TypeScript 1.6 you can use intersection types:

    type CheckListItem = T & {
      isChecked: KnockoutObservable;
    };
    

提交回复
热议问题