knockout.js - Extending a generic parameter in Typescript -
i want create utility function creates checklist adding ischecked knockout observable property each item in array. function should this:
createchecklist<t>(allentities: t[], selected: t[]) : checklistitem<t> { ... } i returning checklistitem<t> because interface should extend t add ischecked property. however, typescript not allow me this:
interface checklistitem<t> extends t { ischecked: knockoutobservable<boolean>; } gives me error:
an interface may extend class or interface.
is there way this?
there isn't way express in typescript.
you can instead:
interface checklistitem<t> { ischecked: knockoutobservable<boolean>; item: t; } this has advantage of not breaking object when happens have own ischecked property.
Comments
Post a Comment