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

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

java - Copying object fields -

c++ - Clear the memory after returning a vector in a function -