declare var ko: KnockoutStatic; interface KnockoutStatic { protectedObservable: (initialValue: any) => any; dependentObservable(p: { read: KnockoutObservable; write: (newValue: any) => void }); } interface KnockoutObservable { protectedObservable: (initialValue: any) => any; reset: () => void; commit: (vaule?: any) => void; } ko.protectedObservable = (initialValue) => { let temp = initialValue; const actual = ko.observable(initialValue); const result = ko.dependentObservable({ read: actual, write: (newValue) => { temp = newValue; } }).extend({ notify: 'always' }); result.commit = (value?: any) => { if (value) { actual(value); } else { if (temp !== actual()) { actual(temp); } } }; result.reset = () => { actual.valueHasMutated(); temp = actual(); }; return result; };