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
There isn't a way to express this in TypeScript.
You can obviously do this instead:
interface CheckListItem<T> {
isChecked: KnockoutObservable<boolean>;
item: T;
}
This has the advantage of not breaking the object when it happens to have its own isChecked
property.
Since TypeScript 1.6 you can use intersection types:
type CheckListItem<T> = T & {
isChecked: KnockoutObservable<boolean>;
};